1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/ucx/test.c Sat Feb 18 15:50:43 2012 +0100 1.3 @@ -0,0 +1,39 @@ 1.4 +/* 1.5 + * File: test.c 1.6 + * Author: Mike 1.7 + * 1.8 + * Created on 18. Februar 2012, 14:15 1.9 + */ 1.10 + 1.11 +#include "test.h" 1.12 + 1.13 +UcxTestSuite* ucx_test_suite_new() { 1.14 + UcxTestSuite* suite = (UcxTestSuite*) malloc(sizeof(UcxTestSuite)); 1.15 + if (suite != NULL) { 1.16 + suite->success = 0; 1.17 + suite->failure = 0; 1.18 + suite->tests = NULL; 1.19 + } 1.20 + return suite; 1.21 +} 1.22 + 1.23 +void ucx_test_suite_free(UcxTestSuite* suite) { 1.24 + ucx_list_free(suite->tests); 1.25 + free(suite); 1.26 +} 1.27 + 1.28 +void ucx_test_register(UcxTestSuite* suite, UcxTest test) { 1.29 + suite->tests = ucx_list_append(suite->tests, (void*) test); 1.30 +} 1.31 + 1.32 +void ucx_test_run(UcxTestSuite* suite, FILE* output) { 1.33 + suite->success = 0; 1.34 + suite->failure = 0; 1.35 + UCX_FOREACH (UcxList*, suite->tests, e) { 1.36 + UcxTest test = (UcxTest) (e->data); 1.37 + test(suite, output); 1.38 + } 1.39 + fwrite("\nAll test completed.\n", 1, 21, output); 1.40 + fprintf(output, " Total: %d\n Success: %d\n Failure: %d\n", 1.41 + suite->success+suite->failure, suite->success, suite->failure); 1.42 +}