diff -r 59f147baea31 -r 22644e2572bc test/main.c --- a/test/main.c Sat Feb 18 15:50:43 2012 +0100 +++ b/test/main.c Sat Feb 18 18:36:30 2012 +0100 @@ -31,10 +31,26 @@ #include "ucx/test.h" +#include "main.h" + #include "list_tests.h" +#include "dlist_tests.h" + #include "mpool_tests.h" #include "map_tests.h" +int cmp_string(void* o1, void* o2, void* data) { + return strcmp((char*)o1, (char*)o2); +} + +void* copy_string(void* e, void* data) { + char *str = (char*) e; + size_t n = 1+strlen(str); + char *cpy = (char*) malloc(n); + memcpy(cpy, str, n); + return cpy; +} + UCX_TEST_BEGIN(testTestSuitePositive) { UCX_TEST_ASSERT(2*2 == 4, "the test framework fails") UCX_TEST_END @@ -48,22 +64,39 @@ int main(int argc, char **argv) { printf("UCX Tests\n---------\n"); - printf("\nUcxTestSuite Tests\n"); + printf("\nUcxTestSuite Tests (1 failure is intended!)\n"); UcxTestSuite* suite = ucx_test_suite_new(); ucx_test_register(suite, testTestSuitePositive); ucx_test_register(suite, testTestSuiteNegative); ucx_test_run(suite, stdout); if (suite->failure == 1 && suite->success == 1) { ucx_test_suite_free(suite); - + + suite = ucx_test_suite_new(); + /* UcxList Tests */ + ucx_test_register(suite, test_ucx_list_append); + ucx_test_register(suite, test_ucx_list_prepend); + ucx_test_register(suite, test_ucx_list_equals); + ucx_test_register(suite, test_ucx_list_concat); + ucx_test_register(suite, test_ucx_list_size); + ucx_test_register(suite, test_ucx_list_last); + ucx_test_register(suite, test_ucx_list_get); + ucx_test_register(suite, test_ucx_list_remove); + ucx_test_register(suite, test_ucx_list_clone); + + /* UcxDlist Tests */ + ucx_test_register(suite, test_ucx_dlist_append); + ucx_test_register(suite, test_ucx_dlist_prepend); + ucx_test_register(suite, test_ucx_dlist_equals); + ucx_test_register(suite, test_ucx_dlist_concat); + ucx_test_register(suite, test_ucx_dlist_size); + ucx_test_register(suite, test_ucx_dlist_first); + ucx_test_register(suite, test_ucx_dlist_last); + ucx_test_register(suite, test_ucx_dlist_get); + ucx_test_register(suite, test_ucx_dlist_remove); + ucx_test_register(suite, test_ucx_dlist_clone); + /* TODO: replace these tests with "real" tests */ - printf("\nUcxDlist Tests\n"); - if(dlist_tests()) { - fprintf(stderr, "dlist_tests failed\n"); - } - - printf("\nUcxList Tests\n Assumed to be correct\n"); - printf("\nUcxMemPool Tests\n"); if(mpool_tests()) { fprintf(stderr, "mpool_tests failed\n"); @@ -74,6 +107,9 @@ fprintf(stderr, "map_tests failed\n"); } + ucx_test_run(suite, stdout); + ucx_test_suite_free(suite); + return EXIT_SUCCESS; } else { ucx_test_suite_free(suite);