1.1 --- a/test/main.c Thu Feb 09 10:40:19 2012 +0100 1.2 +++ b/test/main.c Sat Feb 18 15:50:43 2012 +0100 1.3 @@ -29,30 +29,55 @@ 1.4 #include <stdio.h> 1.5 #include <stdlib.h> 1.6 1.7 +#include "ucx/test.h" 1.8 + 1.9 #include "list_tests.h" 1.10 #include "mpool_tests.h" 1.11 #include "map_tests.h" 1.12 1.13 +UCX_TEST_BEGIN(testTestSuitePositive) { 1.14 + UCX_TEST_ASSERT(2*2 == 4, "the test framework fails") 1.15 + UCX_TEST_END 1.16 +} 1.17 + 1.18 +UCX_TEST_BEGIN(testTestSuiteNegative) { 1.19 + UCX_TEST_ASSERT(2*(-2) == 4, "the test framework works") 1.20 + UCX_TEST_END 1.21 +} 1.22 + 1.23 int main(int argc, char **argv) { 1.24 printf("UCX Tests\n---------\n"); 1.25 1.26 - printf("\nUcxDlist Tests\n"); 1.27 - if(dlist_tests()) { 1.28 - fprintf(stderr, "dlist_tests failed\n"); 1.29 + printf("\nUcxTestSuite Tests\n"); 1.30 + UcxTestSuite* suite = ucx_test_suite_new(); 1.31 + ucx_test_register(suite, testTestSuitePositive); 1.32 + ucx_test_register(suite, testTestSuiteNegative); 1.33 + ucx_test_run(suite, stdout); 1.34 + if (suite->failure == 1 && suite->success == 1) { 1.35 + ucx_test_suite_free(suite); 1.36 + 1.37 + /* TODO: replace these tests with "real" tests */ 1.38 + printf("\nUcxDlist Tests\n"); 1.39 + if(dlist_tests()) { 1.40 + fprintf(stderr, "dlist_tests failed\n"); 1.41 + } 1.42 + 1.43 + printf("\nUcxList Tests\n Assumed to be correct\n"); 1.44 + 1.45 + printf("\nUcxMemPool Tests\n"); 1.46 + if(mpool_tests()) { 1.47 + fprintf(stderr, "mpool_tests failed\n"); 1.48 + } 1.49 + 1.50 + printf("\nUcxMap Tests\n"); 1.51 + if(map_tests()) { 1.52 + fprintf(stderr, "map_tests failed\n"); 1.53 + } 1.54 + 1.55 + return EXIT_SUCCESS; 1.56 + } else { 1.57 + ucx_test_suite_free(suite); 1.58 + return EXIT_FAILURE; 1.59 } 1.60 - 1.61 - printf("\nUcxList Tests\n Assumed to be correct\n"); 1.62 - 1.63 - printf("\nUcxMemPool Tests\n"); 1.64 - if(mpool_tests()) { 1.65 - fprintf(stderr, "mpool_tests failed\n"); 1.66 - } 1.67 - 1.68 - printf("\nUcxMap Tests\n"); 1.69 - if(map_tests()) { 1.70 - fprintf(stderr, "map_tests failed\n"); 1.71 - } 1.72 - 1.73 - return EXIT_SUCCESS; 1.74 } 1.75