diff -r 0f94d369bb02 -r 1bcaac272cdf ucx/test.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ucx/test.c Fri Nov 30 21:18:13 2012 +0100 @@ -0,0 +1,39 @@ +/* + * File: test.c + * Author: Mike + * + * Created on 18. Februar 2012, 14:15 + */ + +#include "test.h" + +UcxTestSuite* ucx_test_suite_new() { + UcxTestSuite* suite = (UcxTestSuite*) malloc(sizeof(UcxTestSuite)); + if (suite != NULL) { + suite->success = 0; + suite->failure = 0; + suite->tests = NULL; + } + return suite; +} + +void ucx_test_suite_free(UcxTestSuite* suite) { + ucx_list_free(suite->tests); + free(suite); +} + +void ucx_test_register(UcxTestSuite* suite, UcxTest test) { + suite->tests = ucx_list_append(suite->tests, (void*) test); +} + +void ucx_test_run(UcxTestSuite* suite, FILE* output) { + suite->success = 0; + suite->failure = 0; + UCX_FOREACH (UcxList*, suite->tests, e) { + UcxTest test = (UcxTest) (e->data); + test(suite, output); + } + fwrite("\nAll test completed.\n", 1, 21, output); + fprintf(output, " Total: %d\n Success: %d\n Failure: %d\n", + suite->success+suite->failure, suite->success, suite->failure); +}