Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5564 serge 1
/*
2
 * Copyright 2011 Tom Stellard 
3
 *
4
 * All Rights Reserved.
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining
7
 * a copy of this software and associated documentation files (the
8
 * "Software"), to deal in the Software without restriction, including
9
 * without limitation the rights to use, copy, modify, merge, publish,
10
 * distribute, sublicense, and/or sell copies of the Software, and to
11
 * permit persons to whom the Software is furnished to do so, subject to
12
 * the following conditions:
13
 *
14
 * The above copyright notice and this permission notice (including the
15
 * next paragraph) shall be included in all copies or substantial
16
 * portions of the Software.
17
 *
18
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21
 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
 *
26
 */
27
 
28
#include 
29
#include 
30
#include 
31
 
32
#include "unit_test.h"
33
 
34
unsigned run_tests(struct test tests[])
35
{
36
	int i;
37
	unsigned pass = 1;
38
	for (i = 0; tests[i].name; i++) {
39
		printf("Test %s\n", tests[i].name);
40
		memset(&tests[i].result, 0, sizeof(tests[i].result));
41
		tests[i].test_func(&tests[i].result);
42
		printf("Test %s (%d/%d) pass\n", tests[i].name,
43
			tests[i].result.pass, tests[i].result.test_count);
44
		if (tests[i].result.pass != tests[i].result.test_count) {
45
			pass = 0;
46
		}
47
	}
48
	return pass;
49
}
50
 
51
void test_begin(struct test_result * result)
52
{
53
	result->test_count++;
54
}
55
 
56
void test_check(struct test_result * result, int cond)
57
{
58
	printf("Subtest %u -> ", result->test_count);
59
	if (cond) {
60
		result->pass++;
61
		printf("Pass");
62
	} else {
63
		result->fail++;
64
		printf("Fail");
65
	}
66
	printf("\n");
67
}