ucx/test.c

changeset 1
1bcaac272cdf
child 5
88625853ae74
equal deleted inserted replaced
0:0f94d369bb02 1:1bcaac272cdf
1 /*
2 * File: test.c
3 * Author: Mike
4 *
5 * Created on 18. Februar 2012, 14:15
6 */
7
8 #include "test.h"
9
10 UcxTestSuite* ucx_test_suite_new() {
11 UcxTestSuite* suite = (UcxTestSuite*) malloc(sizeof(UcxTestSuite));
12 if (suite != NULL) {
13 suite->success = 0;
14 suite->failure = 0;
15 suite->tests = NULL;
16 }
17 return suite;
18 }
19
20 void ucx_test_suite_free(UcxTestSuite* suite) {
21 ucx_list_free(suite->tests);
22 free(suite);
23 }
24
25 void ucx_test_register(UcxTestSuite* suite, UcxTest test) {
26 suite->tests = ucx_list_append(suite->tests, (void*) test);
27 }
28
29 void ucx_test_run(UcxTestSuite* suite, FILE* output) {
30 suite->success = 0;
31 suite->failure = 0;
32 UCX_FOREACH (UcxList*, suite->tests, e) {
33 UcxTest test = (UcxTest) (e->data);
34 test(suite, output);
35 }
36 fwrite("\nAll test completed.\n", 1, 21, output);
37 fprintf(output, " Total: %d\n Success: %d\n Failure: %d\n",
38 suite->success+suite->failure, suite->success, suite->failure);
39 }

mercurial