1.1 --- a/ucx/test.c Fri Feb 08 11:25:04 2013 +0100 1.2 +++ b/ucx/test.c Fri Feb 08 17:09:12 2013 +0100 1.3 @@ -18,20 +18,45 @@ 1.4 } 1.5 1.6 void ucx_test_suite_free(UcxTestSuite* suite) { 1.7 - ucx_list_free(suite->tests); 1.8 + UcxTestList *l = suite->tests; 1.9 + while (l != NULL) { 1.10 + UcxTestList *e = l; 1.11 + l = l->next; 1.12 + free(e); 1.13 + } 1.14 free(suite); 1.15 } 1.16 1.17 -void ucx_test_register(UcxTestSuite* suite, UcxTest test) { 1.18 - suite->tests = ucx_list_append(suite->tests, (void*) test); 1.19 +int ucx_test_register(UcxTestSuite* suite, UcxTest test) { 1.20 + if (suite->tests) { 1.21 + UcxTestList *list = (UcxTestList*) malloc(sizeof(UcxTestList)); 1.22 + if (list) { 1.23 + list->test = test; 1.24 + list->next = suite->tests; 1.25 + suite->tests = list; 1.26 + 1.27 + return EXIT_SUCCESS; 1.28 + } else { 1.29 + return EXIT_FAILURE; 1.30 + } 1.31 + } else { 1.32 + suite->tests = (UcxTestList*) malloc(sizeof(UcxTestList)); 1.33 + if (suite->tests) { 1.34 + suite->tests->test = test; 1.35 + suite->tests->next = NULL; 1.36 + 1.37 + return EXIT_SUCCESS; 1.38 + } else { 1.39 + return EXIT_FAILURE; 1.40 + } 1.41 + } 1.42 } 1.43 1.44 void ucx_test_run(UcxTestSuite* suite, FILE* output) { 1.45 suite->success = 0; 1.46 suite->failure = 0; 1.47 - UCX_FOREACH (UcxList*, suite->tests, e) { 1.48 - UcxTest test = (UcxTest) (e->data); 1.49 - test(suite, output); 1.50 + UCX_FOREACH (UcxTestList*, suite->tests, e) { 1.51 + e->test(suite, output); 1.52 } 1.53 fwrite("\nAll test completed.\n", 1, 21, output); 1.54 fprintf(output, " Total: %d\n Success: %d\n Failure: %d\n",