Fri, 09 Aug 2013 11:32:10 +0200
documented test.h and removed duplicated implement/declare macros for UCX_TEST
1.1 --- a/test/buffer_tests.c Fri Aug 09 10:24:02 2013 +0200 1.2 +++ b/test/buffer_tests.c Fri Aug 09 11:32:10 2013 +0200 1.3 @@ -28,7 +28,7 @@ 1.4 1.5 #include "buffer_tests.h" 1.6 1.7 -UCX_TEST_IMPLEMENT(test_ucx_buffer_seektell) { 1.8 +UCX_TEST(test_ucx_buffer_seektell) { 1.9 UcxBuffer *b = ucx_buffer_new(NULL, 32, UCX_BUFFER_DEFAULT); 1.10 b->size = 16; // less than capacity 1.11 int r; 1.12 @@ -67,7 +67,7 @@ 1.13 ucx_buffer_free(b); 1.14 } 1.15 1.16 -UCX_TEST_IMPLEMENT(test_ucx_buffer_putc) { 1.17 +UCX_TEST(test_ucx_buffer_putc) { 1.18 char *buffer = (char*) malloc(16); 1.19 memset(buffer, 32, 16); 1.20 1.21 @@ -107,7 +107,7 @@ 1.22 free(buffer); 1.23 } 1.24 1.25 -UCX_TEST_IMPLEMENT(test_ucx_buffer_putc_ax) { 1.26 +UCX_TEST(test_ucx_buffer_putc_ax) { 1.27 UcxBuffer *b = ucx_buffer_new(NULL, 2, UCX_BUFFER_AUTOEXTEND); 1.28 1.29 UCX_TEST_BEGIN 1.30 @@ -131,7 +131,7 @@ 1.31 1.32 } 1.33 1.34 -UCX_TEST_IMPLEMENT(test_ucx_buffer_getc) { 1.35 +UCX_TEST(test_ucx_buffer_getc) { 1.36 char *buffer = (char*) malloc(16); 1.37 memset(buffer, 32, 8); 1.38 for (int i = 8; i < 16 ; i++) { 1.39 @@ -161,7 +161,7 @@ 1.40 free(buffer); 1.41 } 1.42 1.43 -UCX_TEST_IMPLEMENT(test_ucx_buffer_write) { 1.44 +UCX_TEST(test_ucx_buffer_write) { 1.45 char *buffer = (char*) malloc(16); 1.46 memset(buffer, 32, 8); 1.47 for (int i = 8; i < 16 ; i++) { 1.48 @@ -203,7 +203,7 @@ 1.49 free(buffer); 1.50 } 1.51 1.52 -UCX_TEST_IMPLEMENT(test_ucx_buffer_write_ax) { 1.53 +UCX_TEST(test_ucx_buffer_write_ax) { 1.54 char *buffer = (char*) malloc(16); 1.55 1.56 UcxBuffer *b = ucx_buffer_new(buffer, 16, 1.57 @@ -227,7 +227,7 @@ 1.58 ucx_buffer_free(b); 1.59 } 1.60 1.61 -UCX_TEST_IMPLEMENT(test_ucx_buffer_read) { 1.62 +UCX_TEST(test_ucx_buffer_read) { 1.63 UcxBuffer *b = ucx_buffer_new(NULL, 8, UCX_BUFFER_AUTOFREE); 1.64 1.65 char buf[32]; 1.66 @@ -264,7 +264,7 @@ 1.67 1.68 } 1.69 1.70 -UCX_TEST_IMPLEMENT(test_ucx_buffer_extract) { 1.71 +UCX_TEST(test_ucx_buffer_extract) { 1.72 char *buffer = (char*) malloc(16); 1.73 strcpy(buffer, "this is a test!"); 1.74 1.75 @@ -292,7 +292,7 @@ 1.76 ucx_buffer_free(src); 1.77 } 1.78 1.79 -UCX_TEST_IMPLEMENT(test_ucx_buffer_generic_copy) { 1.80 +UCX_TEST(test_ucx_buffer_generic_copy) { 1.81 UcxBuffer *b1 = ucx_buffer_new(NULL, 64, UCX_BUFFER_DEFAULT); 1.82 UcxBuffer *b2 = ucx_buffer_new(NULL, 2, UCX_BUFFER_AUTOEXTEND); 1.83
2.1 --- a/test/buffer_tests.h Fri Aug 09 10:24:02 2013 +0200 2.2 +++ b/test/buffer_tests.h Fri Aug 09 11:32:10 2013 +0200 2.3 @@ -38,15 +38,15 @@ 2.4 2.5 /* assume open and close to be correct */ 2.6 2.7 -UCX_TEST_DECLARE(test_ucx_buffer_seektell); 2.8 -UCX_TEST_DECLARE(test_ucx_buffer_putc); 2.9 -UCX_TEST_DECLARE(test_ucx_buffer_putc_ax); 2.10 -UCX_TEST_DECLARE(test_ucx_buffer_getc); 2.11 -UCX_TEST_DECLARE(test_ucx_buffer_write); 2.12 -UCX_TEST_DECLARE(test_ucx_buffer_write_ax); 2.13 -UCX_TEST_DECLARE(test_ucx_buffer_read); 2.14 -UCX_TEST_DECLARE(test_ucx_buffer_extract); 2.15 -UCX_TEST_DECLARE(test_ucx_buffer_generic_copy); 2.16 +UCX_TEST(test_ucx_buffer_seektell); 2.17 +UCX_TEST(test_ucx_buffer_putc); 2.18 +UCX_TEST(test_ucx_buffer_putc_ax); 2.19 +UCX_TEST(test_ucx_buffer_getc); 2.20 +UCX_TEST(test_ucx_buffer_write); 2.21 +UCX_TEST(test_ucx_buffer_write_ax); 2.22 +UCX_TEST(test_ucx_buffer_read); 2.23 +UCX_TEST(test_ucx_buffer_extract); 2.24 +UCX_TEST(test_ucx_buffer_generic_copy); 2.25 2.26 #ifdef __cplusplus 2.27 }
3.1 --- a/test/list_tests.c Fri Aug 09 10:24:02 2013 +0200 3.2 +++ b/test/list_tests.c Fri Aug 09 11:32:10 2013 +0200 3.3 @@ -29,7 +29,7 @@ 3.4 #include "list_tests.h" 3.5 #include "ucx/utils.h" 3.6 3.7 -UCX_TEST_IMPLEMENT(test_ucx_list_append) { 3.8 +UCX_TEST(test_ucx_list_append) { 3.9 UcxList *list = ucx_list_append(NULL, (void*)"Hello"); 3.10 UCX_TEST_BEGIN 3.11 3.12 @@ -46,7 +46,7 @@ 3.13 ucx_list_free(list); 3.14 } 3.15 3.16 -UCX_TEST_IMPLEMENT(test_ucx_list_prepend) { 3.17 +UCX_TEST(test_ucx_list_prepend) { 3.18 UcxList *list = ucx_list_prepend(NULL, (void*)" World!"); 3.19 UCX_TEST_BEGIN 3.20 3.21 @@ -62,7 +62,7 @@ 3.22 ucx_list_free(list); 3.23 } 3.24 3.25 -UCX_TEST_IMPLEMENT(test_ucx_list_equals) { 3.26 +UCX_TEST(test_ucx_list_equals) { 3.27 UcxList *list = ucx_list_append(NULL, (void*)"Hello"); 3.28 list = ucx_list_append(list, (void*)" World!"); 3.29 UcxList *list2 = ucx_list_prepend(NULL, (void*)" World!"); 3.30 @@ -80,7 +80,7 @@ 3.31 ucx_list_free(list); 3.32 } 3.33 3.34 -UCX_TEST_IMPLEMENT(test_ucx_list_concat) { 3.35 +UCX_TEST(test_ucx_list_concat) { 3.36 UcxList *list = ucx_list_append(NULL, (void*)"Hello"); 3.37 UcxList *list2 = ucx_list_prepend(NULL, (void*)" World!"); 3.38 UCX_TEST_BEGIN 3.39 @@ -97,7 +97,7 @@ 3.40 ucx_list_free(list); 3.41 } 3.42 3.43 -UCX_TEST_IMPLEMENT(test_ucx_list_size) { 3.44 +UCX_TEST(test_ucx_list_size) { 3.45 UcxList *list = ucx_list_append(NULL, (void*)"This "); 3.46 list = ucx_list_append(list, (void*)"list "); 3.47 list = ucx_list_append(list, (void*)"has "); 3.48 @@ -112,7 +112,7 @@ 3.49 ucx_list_free(list); 3.50 } 3.51 3.52 -UCX_TEST_IMPLEMENT(test_ucx_list_first) { 3.53 +UCX_TEST(test_ucx_list_first) { 3.54 UcxList *list = ucx_list_append(NULL, (void*)"Find "); 3.55 list = ucx_list_append(list, (void*)"the "); 3.56 list = ucx_list_append(list, (void*)"first!"); 3.57 @@ -127,7 +127,7 @@ 3.58 ucx_list_free(list); 3.59 } 3.60 3.61 -UCX_TEST_IMPLEMENT(test_ucx_list_last) { 3.62 +UCX_TEST(test_ucx_list_last) { 3.63 UcxList *list = ucx_list_append(NULL, (void*)"Find "); 3.64 list = ucx_list_append(list, (void*)"the "); 3.65 list = ucx_list_append(list, (void*)"last!"); 3.66 @@ -142,7 +142,7 @@ 3.67 ucx_list_free(list); 3.68 } 3.69 3.70 -UCX_TEST_IMPLEMENT(test_ucx_list_get) { 3.71 +UCX_TEST(test_ucx_list_get) { 3.72 UcxList *list = ucx_list_append(NULL, (void*)"Find "); 3.73 list = ucx_list_append(list, (void*)"the "); 3.74 list = ucx_list_append(list, (void*)"mid!"); 3.75 @@ -157,7 +157,7 @@ 3.76 ucx_list_free(list); 3.77 } 3.78 3.79 -UCX_TEST_IMPLEMENT(test_ucx_list_indexof) { 3.80 +UCX_TEST(test_ucx_list_indexof) { 3.81 UcxList *list = ucx_list_append(NULL, (void*)"Find "); 3.82 list = ucx_list_append(list, (void*)"the "); 3.83 list = ucx_list_append(list, (void*)"mid!"); 3.84 @@ -177,7 +177,7 @@ 3.85 ucx_list_free(list); 3.86 } 3.87 3.88 -UCX_TEST_IMPLEMENT(test_ucx_list_find) { 3.89 +UCX_TEST(test_ucx_list_find) { 3.90 UcxList *l = ucx_list_append(NULL, (void*)"find "); 3.91 l = ucx_list_append(l, (void*)"some "); 3.92 l = ucx_list_append(l, (void*)"string!"); 3.93 @@ -193,7 +193,7 @@ 3.94 ucx_list_free(l); 3.95 } 3.96 3.97 -UCX_TEST_IMPLEMENT(test_ucx_list_contains) { 3.98 +UCX_TEST(test_ucx_list_contains) { 3.99 UcxList *l = ucx_list_append(NULL, (void*)"Contains "); 3.100 l = ucx_list_append(l, (void*)"a "); 3.101 l = ucx_list_append(l, (void*)"string!"); 3.102 @@ -209,7 +209,7 @@ 3.103 ucx_list_free(l); 3.104 } 3.105 3.106 -UCX_TEST_IMPLEMENT(test_ucx_list_remove) { 3.107 +UCX_TEST(test_ucx_list_remove) { 3.108 UcxList *list = ucx_list_append(NULL, (void*)"Hello"); 3.109 list = ucx_list_append(list, (void*)" fucking"); 3.110 list = ucx_list_append(list, (void*)" World!"); 3.111 @@ -228,7 +228,7 @@ 3.112 ucx_list_free(list); 3.113 } 3.114 3.115 -UCX_TEST_IMPLEMENT(test_ucx_list_clone) { 3.116 +UCX_TEST(test_ucx_list_clone) { 3.117 3.118 char *hello = (char*)malloc(6); 3.119 char *world = (char*)malloc(8); 3.120 @@ -256,7 +256,7 @@ 3.121 ucx_list_free(copy); 3.122 } 3.123 3.124 -UCX_TEST_IMPLEMENT(test_ucx_list_sort) { 3.125 +UCX_TEST(test_ucx_list_sort) { 3.126 UcxList *list = ucx_list_append(NULL, (void*)"this"); 3.127 list = ucx_list_append(list, (void*)"is"); 3.128 list = ucx_list_append(list, (void*)"a");
4.1 --- a/test/list_tests.h Fri Aug 09 10:24:02 2013 +0200 4.2 +++ b/test/list_tests.h Fri Aug 09 11:32:10 2013 +0200 4.3 @@ -43,20 +43,20 @@ 4.4 * ucx_list_free 4.5 */ 4.6 4.7 -UCX_TEST_DECLARE(test_ucx_list_append); 4.8 -UCX_TEST_DECLARE(test_ucx_list_prepend); 4.9 -UCX_TEST_DECLARE(test_ucx_list_equals); 4.10 -UCX_TEST_DECLARE(test_ucx_list_concat); 4.11 -UCX_TEST_DECLARE(test_ucx_list_size); 4.12 -UCX_TEST_DECLARE(test_ucx_list_first); 4.13 -UCX_TEST_DECLARE(test_ucx_list_last); 4.14 -UCX_TEST_DECLARE(test_ucx_list_get); 4.15 -UCX_TEST_DECLARE(test_ucx_list_indexof); 4.16 -UCX_TEST_DECLARE(test_ucx_list_find); 4.17 -UCX_TEST_DECLARE(test_ucx_list_contains); 4.18 -UCX_TEST_DECLARE(test_ucx_list_remove); 4.19 -UCX_TEST_DECLARE(test_ucx_list_clone); 4.20 -UCX_TEST_DECLARE(test_ucx_list_sort); 4.21 +UCX_TEST(test_ucx_list_append); 4.22 +UCX_TEST(test_ucx_list_prepend); 4.23 +UCX_TEST(test_ucx_list_equals); 4.24 +UCX_TEST(test_ucx_list_concat); 4.25 +UCX_TEST(test_ucx_list_size); 4.26 +UCX_TEST(test_ucx_list_first); 4.27 +UCX_TEST(test_ucx_list_last); 4.28 +UCX_TEST(test_ucx_list_get); 4.29 +UCX_TEST(test_ucx_list_indexof); 4.30 +UCX_TEST(test_ucx_list_find); 4.31 +UCX_TEST(test_ucx_list_contains); 4.32 +UCX_TEST(test_ucx_list_remove); 4.33 +UCX_TEST(test_ucx_list_clone); 4.34 +UCX_TEST(test_ucx_list_sort); 4.35 4.36 #ifdef __cplusplus 4.37 }
5.1 --- a/test/logging_tests.c Fri Aug 09 10:24:02 2013 +0200 5.2 +++ b/test/logging_tests.c Fri Aug 09 11:32:10 2013 +0200 5.3 @@ -28,7 +28,7 @@ 5.4 5.5 #include "logging_tests.h" 5.6 5.7 -UCX_TEST_IMPLEMENT(test_ucx_logger_log) { 5.8 +UCX_TEST(test_ucx_logger_log) { 5.9 char buffer[100]; 5.10 FILE *stream = tmpfile(); 5.11
6.1 --- a/test/logging_tests.h Fri Aug 09 10:24:02 2013 +0200 6.2 +++ b/test/logging_tests.h Fri Aug 09 11:32:10 2013 +0200 6.3 @@ -36,7 +36,7 @@ 6.4 extern "C" { 6.5 #endif 6.6 6.7 -UCX_TEST_DECLARE(test_ucx_logger_log); 6.8 +UCX_TEST(test_ucx_logger_log); 6.9 6.10 #ifdef __cplusplus 6.11 }
7.1 --- a/test/main.c Fri Aug 09 10:24:02 2013 +0200 7.2 +++ b/test/main.c Fri Aug 09 11:32:10 2013 +0200 7.3 @@ -41,13 +41,13 @@ 7.4 #include "prop_tests.h" 7.5 #include "buffer_tests.h" 7.6 7.7 -UCX_EXTERN UCX_TEST_IMPLEMENT(testTestSuitePositive) { 7.8 +UCX_EXTERN UCX_TEST(testTestSuitePositive) { 7.9 UCX_TEST_BEGIN 7.10 UCX_TEST_ASSERT(2*2 == 4, "the test framework fails"); 7.11 UCX_TEST_END 7.12 } 7.13 7.14 -UCX_EXTERN UCX_TEST_IMPLEMENT(testTestSuiteNegative) { 7.15 +UCX_EXTERN UCX_TEST(testTestSuiteNegative) { 7.16 UCX_TEST_BEGIN 7.17 UCX_TEST_ASSERT(2*(-2) == 4, "the test framework works"); 7.18 UCX_TEST_END 7.19 @@ -73,7 +73,7 @@ 7.20 UCX_TEST_ASSERT(*i==4, "the test framework works"); 7.21 } 7.22 7.23 -UCX_EXTERN UCX_TEST_IMPLEMENT(testTestSuiteRoutinePositive) { 7.24 +UCX_EXTERN UCX_TEST(testTestSuiteRoutinePositive) { 7.25 int i = 2; 7.26 UCX_TEST_BEGIN 7.27 UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineSuccess, &i); 7.28 @@ -81,7 +81,7 @@ 7.29 UCX_TEST_END 7.30 } 7.31 7.32 -UCX_EXTERN UCX_TEST_IMPLEMENT(testTestSuiteRoutineNegative) { 7.33 +UCX_EXTERN UCX_TEST(testTestSuiteRoutineNegative) { 7.34 int i = 0; 7.35 UCX_TEST_BEGIN 7.36 UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutineFailure, &i); 7.37 @@ -89,7 +89,7 @@ 7.38 UCX_TEST_END 7.39 } 7.40 7.41 -UCX_EXTERN UCX_TEST_IMPLEMENT(testTestSuiteRoutineMultiparam) { 7.42 +UCX_EXTERN UCX_TEST(testTestSuiteRoutineMultiparam) { 7.43 UCX_TEST_BEGIN 7.44 UCX_TEST_CALL_SUBROUTINE(testTestSuiteRoutine2Param, 42, 3.14f); 7.45 UCX_TEST_END
8.1 --- a/test/map_tests.c Fri Aug 09 10:24:02 2013 +0200 8.2 +++ b/test/map_tests.c Fri Aug 09 11:32:10 2013 +0200 8.3 @@ -28,7 +28,7 @@ 8.4 8.5 #include "map_tests.h" 8.6 8.7 -UCX_TEST_IMPLEMENT(test_ucx_map_new) { 8.8 +UCX_TEST(test_ucx_map_new) { 8.9 UcxMap *map = ucx_map_new(16); 8.10 UCX_TEST_BEGIN 8.11 UCX_TEST_ASSERT(map->size == 16, "wrong size"); 8.12 @@ -38,7 +38,7 @@ 8.13 ucx_map_free(map); 8.14 } 8.15 8.16 -UCX_TEST_IMPLEMENT(test_ucx_key) { 8.17 +UCX_TEST(test_ucx_key) { 8.18 UcxKey key = ucx_key((void*)"This is a text.", 15); 8.19 UCX_TEST_BEGIN 8.20 UCX_TEST_ASSERT(strncmp((const char*)key.data, "This is a text.", 15) == 0, 8.21 @@ -49,7 +49,7 @@ 8.22 UCX_TEST_END 8.23 } 8.24 8.25 -UCX_TEST_IMPLEMENT(test_ucx_map_put) { 8.26 +UCX_TEST(test_ucx_map_put) { 8.27 8.28 UcxMap *map = ucx_map_new(4); 8.29 8.30 @@ -94,7 +94,7 @@ 8.31 ucx_map_free(map); 8.32 } 8.33 8.34 -UCX_TEST_IMPLEMENT(test_ucx_map_get) { 8.35 +UCX_TEST(test_ucx_map_get) { 8.36 UcxMap *map = ucx_map_new(4); 8.37 8.38 int td[5]; 8.39 @@ -125,7 +125,7 @@ 8.40 ucx_map_free(map); 8.41 } 8.42 8.43 -UCX_TEST_IMPLEMENT(test_ucx_map_remove) { 8.44 +UCX_TEST(test_ucx_map_remove) { 8.45 UcxMap *map = ucx_map_new(4); 8.46 8.47 int td[5]; 8.48 @@ -188,7 +188,7 @@ 8.49 UCX_TEST_ASSERT(check == v1+v2+v3+v4, "test1: wrong result"); 8.50 } 8.51 8.52 -UCX_TEST_IMPLEMENT(test_ucx_map_iterator) { 8.53 +UCX_TEST(test_ucx_map_iterator) { 8.54 UcxMap *map = ucx_map_new(16); 8.55 UCX_TEST_BEGIN 8.56 UCX_TEST_CALL_SUBROUTINE(test_ucx_map_itersrt, map) 8.57 @@ -196,7 +196,7 @@ 8.58 ucx_map_free(map); 8.59 } 8.60 8.61 -UCX_TEST_IMPLEMENT(test_ucx_map_iterator_chain) { 8.62 +UCX_TEST(test_ucx_map_iterator_chain) { 8.63 UcxMap *map = ucx_map_new(1); 8.64 UCX_TEST_BEGIN 8.65 UCX_TEST_CALL_SUBROUTINE(test_ucx_map_itersrt, map) 8.66 @@ -204,7 +204,7 @@ 8.67 ucx_map_free(map); 8.68 } 8.69 8.70 -UCX_TEST_IMPLEMENT(test_ucx_map_clone) { 8.71 +UCX_TEST(test_ucx_map_clone) { 8.72 UcxMap *map = ucx_map_new(4); 8.73 8.74 ucx_map_cstr_put(map, "key1", (void*)"value1"); 8.75 @@ -241,7 +241,7 @@ 8.76 ucx_map_free(clone); 8.77 } 8.78 8.79 -UCX_TEST_IMPLEMENT(test_ucx_map_rehash) { 8.80 +UCX_TEST(test_ucx_map_rehash) { 8.81 UcxMap *map = ucx_map_new(4); 8.82 8.83 char keys[10][5];
9.1 --- a/test/map_tests.h Fri Aug 09 10:24:02 2013 +0200 9.2 +++ b/test/map_tests.h Fri Aug 09 11:32:10 2013 +0200 9.3 @@ -36,15 +36,15 @@ 9.4 extern "C" { 9.5 #endif 9.6 9.7 -UCX_TEST_DECLARE(test_ucx_map_new); 9.8 -UCX_TEST_DECLARE(test_ucx_key); 9.9 -UCX_TEST_DECLARE(test_ucx_map_put); 9.10 -UCX_TEST_DECLARE(test_ucx_map_get); 9.11 -UCX_TEST_DECLARE(test_ucx_map_remove); 9.12 -UCX_TEST_DECLARE(test_ucx_map_iterator); 9.13 -UCX_TEST_DECLARE(test_ucx_map_iterator_chain); 9.14 -UCX_TEST_DECLARE(test_ucx_map_clone); 9.15 -UCX_TEST_DECLARE(test_ucx_map_rehash); 9.16 +UCX_TEST(test_ucx_map_new); 9.17 +UCX_TEST(test_ucx_key); 9.18 +UCX_TEST(test_ucx_map_put); 9.19 +UCX_TEST(test_ucx_map_get); 9.20 +UCX_TEST(test_ucx_map_remove); 9.21 +UCX_TEST(test_ucx_map_iterator); 9.22 +UCX_TEST(test_ucx_map_iterator_chain); 9.23 +UCX_TEST(test_ucx_map_clone); 9.24 +UCX_TEST(test_ucx_map_rehash); 9.25 9.26 9.27 #ifdef __cplusplus
10.1 --- a/test/mpool_tests.c Fri Aug 09 10:24:02 2013 +0200 10.2 +++ b/test/mpool_tests.c Fri Aug 09 11:32:10 2013 +0200 10.3 @@ -30,7 +30,7 @@ 10.4 10.5 #include "mpool_tests.h" 10.6 10.7 -UCX_TEST_IMPLEMENT(test_ucx_mempool_new) { 10.8 +UCX_TEST(test_ucx_mempool_new) { 10.9 UcxMempool *pool = ucx_mempool_new(16); 10.10 UCX_TEST_BEGIN 10.11 UCX_TEST_ASSERT(pool->size == 16, "wrong size"); 10.12 @@ -40,7 +40,7 @@ 10.13 ucx_mempool_destroy(pool); 10.14 } 10.15 10.16 -UCX_TEST_IMPLEMENT(test_ucx_mempool_malloc) { 10.17 +UCX_TEST(test_ucx_mempool_malloc) { 10.18 10.19 UcxMempool *pool = ucx_mempool_new(1); 10.20 UCX_TEST_BEGIN 10.21 @@ -59,7 +59,7 @@ 10.22 ucx_mempool_destroy(pool); 10.23 } 10.24 10.25 -UCX_TEST_IMPLEMENT(test_ucx_mempool_malloc_with_chcap) { 10.26 +UCX_TEST(test_ucx_mempool_malloc_with_chcap) { 10.27 10.28 UcxMempool *pool = ucx_mempool_new(1); 10.29 UCX_TEST_BEGIN 10.30 @@ -79,7 +79,7 @@ 10.31 ucx_mempool_destroy(pool); 10.32 } 10.33 10.34 -UCX_TEST_IMPLEMENT(test_ucx_mempool_calloc) { 10.35 +UCX_TEST(test_ucx_mempool_calloc) { 10.36 10.37 UcxMempool *pool = ucx_mempool_new(1); 10.38 UCX_TEST_BEGIN 10.39 @@ -93,7 +93,7 @@ 10.40 ucx_mempool_destroy(pool); 10.41 } 10.42 10.43 -UCX_TEST_IMPLEMENT(test_ucx_mempool_free) { 10.44 +UCX_TEST(test_ucx_mempool_free) { 10.45 UcxMempool *pool = ucx_mempool_new(16); 10.46 void *mem1; 10.47 void *mem2; 10.48 @@ -128,7 +128,7 @@ 10.49 *cb = 42; 10.50 } 10.51 10.52 -UCX_TEST_IMPLEMENT(test_ucx_mempool_set_destr) { 10.53 +UCX_TEST(test_ucx_mempool_set_destr) { 10.54 10.55 intptr_t *cb = (intptr_t*) malloc(sizeof(intptr_t)); 10.56 UCX_TEST_BEGIN 10.57 @@ -157,7 +157,7 @@ 10.58 } 10.59 10.60 10.61 -UCX_TEST_IMPLEMENT(test_ucx_mempool_reg_destr) { 10.62 +UCX_TEST(test_ucx_mempool_reg_destr) { 10.63 10.64 intptr_t *test = (intptr_t*) calloc(2, sizeof(intptr_t)); 10.65 intptr_t *cb = (intptr_t*) malloc(sizeof(intptr_t)); 10.66 @@ -184,7 +184,7 @@ 10.67 if (cb != NULL) free(cb); 10.68 } 10.69 10.70 -UCX_TEST_IMPLEMENT(test_ucx_mempool_realloc) { 10.71 +UCX_TEST(test_ucx_mempool_realloc) { 10.72 10.73 intptr_t *cb = (intptr_t*) malloc(sizeof(intptr_t)); 10.74 UCX_TEST_BEGIN
11.1 --- a/test/mpool_tests.h Fri Aug 09 10:24:02 2013 +0200 11.2 +++ b/test/mpool_tests.h Fri Aug 09 11:32:10 2013 +0200 11.3 @@ -36,14 +36,14 @@ 11.4 extern "C" { 11.5 #endif 11.6 11.7 -UCX_TEST_DECLARE(test_ucx_mempool_new); 11.8 -UCX_TEST_DECLARE(test_ucx_mempool_malloc); 11.9 -UCX_TEST_DECLARE(test_ucx_mempool_malloc_with_chcap); 11.10 -UCX_TEST_DECLARE(test_ucx_mempool_calloc); 11.11 -UCX_TEST_DECLARE(test_ucx_mempool_free); 11.12 -UCX_TEST_DECLARE(test_ucx_mempool_set_destr); 11.13 -UCX_TEST_DECLARE(test_ucx_mempool_reg_destr); 11.14 -UCX_TEST_DECLARE(test_ucx_mempool_realloc); 11.15 +UCX_TEST(test_ucx_mempool_new); 11.16 +UCX_TEST(test_ucx_mempool_malloc); 11.17 +UCX_TEST(test_ucx_mempool_malloc_with_chcap); 11.18 +UCX_TEST(test_ucx_mempool_calloc); 11.19 +UCX_TEST(test_ucx_mempool_free); 11.20 +UCX_TEST(test_ucx_mempool_set_destr); 11.21 +UCX_TEST(test_ucx_mempool_reg_destr); 11.22 +UCX_TEST(test_ucx_mempool_realloc); 11.23 11.24 #ifdef __cplusplus 11.25 }
12.1 --- a/test/prop_tests.c Fri Aug 09 10:24:02 2013 +0200 12.2 +++ b/test/prop_tests.c Fri Aug 09 11:32:10 2013 +0200 12.3 @@ -28,7 +28,7 @@ 12.4 12.5 #include "prop_tests.h" 12.6 12.7 -UCX_TEST_IMPLEMENT(test_ucx_properties_new) { 12.8 +UCX_TEST(test_ucx_properties_new) { 12.9 UcxProperties *parser = ucx_properties_new(); 12.10 12.11 UCX_TEST_BEGIN 12.12 @@ -42,7 +42,7 @@ 12.13 ucx_properties_free(parser); 12.14 } 12.15 12.16 -UCX_TEST_IMPLEMENT(test_ucx_properties_next) { 12.17 +UCX_TEST(test_ucx_properties_next) { 12.18 const char *tests[] = { 12.19 "name = value\n", 12.20 "name=value\n", 12.21 @@ -113,7 +113,7 @@ 12.22 UCX_TEST_END 12.23 } 12.24 12.25 -UCX_TEST_IMPLEMENT(test_ucx_properties_next_multi) { 12.26 +UCX_TEST(test_ucx_properties_next_multi) { 12.27 const char *names[] = { 12.28 "a", 12.29 "b", 12.30 @@ -176,7 +176,7 @@ 12.31 ucx_properties_free(parser); 12.32 } 12.33 12.34 -UCX_TEST_IMPLEMENT(test_ucx_properties_next_part) { 12.35 +UCX_TEST(test_ucx_properties_next_part) { 12.36 UcxProperties *parser = ucx_properties_new(); 12.37 const char *str; 12.38 int r; 12.39 @@ -286,7 +286,7 @@ 12.40 ucx_properties_free(parser); 12.41 } 12.42 12.43 -UCX_TEST_IMPLEMENT(test_ucx_properties_next_long) { 12.44 +UCX_TEST(test_ucx_properties_next_long) { 12.45 UcxProperties *parser = ucx_properties_new(); 12.46 int r; 12.47 size_t name_len = 512; 12.48 @@ -362,7 +362,7 @@ 12.49 ucx_properties_free(parser); 12.50 } 12.51 12.52 -UCX_TEST_IMPLEMENT(test_ucx_properties2map) { 12.53 +UCX_TEST(test_ucx_properties2map) { 12.54 UcxMap *map = ucx_map_new(16); 12.55 UcxProperties *parser = ucx_properties_new(); 12.56 12.57 @@ -417,7 +417,7 @@ 12.58 ucx_properties_free(parser); 12.59 } 12.60 12.61 -UCX_TEST_IMPLEMENT(test_ucx_properties_load) { 12.62 +UCX_TEST(test_ucx_properties_load) { 12.63 UCX_TEST_BEGIN 12.64 FILE *f = tmpfile(); 12.65 UCX_TEST_ASSERT(f, "test file cannot be opened, test aborted"); 12.66 @@ -480,7 +480,7 @@ 12.67 UCX_TEST_END 12.68 } 12.69 12.70 -UCX_TEST_IMPLEMENT(test_ucx_properties_store) { 12.71 +UCX_TEST(test_ucx_properties_store) { 12.72 UcxMap *map1 = ucx_map_new(16); 12.73 ucx_map_cstr_put(map1, "key1", "value1"); 12.74 ucx_map_cstr_put(map1, "key2", "value2");
13.1 --- a/test/prop_tests.h Fri Aug 09 10:24:02 2013 +0200 13.2 +++ b/test/prop_tests.h Fri Aug 09 11:32:10 2013 +0200 13.3 @@ -36,14 +36,14 @@ 13.4 extern "C" { 13.5 #endif 13.6 13.7 -UCX_TEST_DECLARE(test_ucx_properties_new); 13.8 -UCX_TEST_DECLARE(test_ucx_properties_next); 13.9 -UCX_TEST_DECLARE(test_ucx_properties_next_multi); 13.10 -UCX_TEST_DECLARE(test_ucx_properties_next_part); 13.11 -UCX_TEST_DECLARE(test_ucx_properties_next_long); 13.12 -UCX_TEST_DECLARE(test_ucx_properties2map); 13.13 -UCX_TEST_DECLARE(test_ucx_properties_load); 13.14 -UCX_TEST_DECLARE(test_ucx_properties_store); 13.15 +UCX_TEST(test_ucx_properties_new); 13.16 +UCX_TEST(test_ucx_properties_next); 13.17 +UCX_TEST(test_ucx_properties_next_multi); 13.18 +UCX_TEST(test_ucx_properties_next_part); 13.19 +UCX_TEST(test_ucx_properties_next_long); 13.20 +UCX_TEST(test_ucx_properties2map); 13.21 +UCX_TEST(test_ucx_properties_load); 13.22 +UCX_TEST(test_ucx_properties_store); 13.23 13.24 #ifdef __cplusplus 13.25 }
14.1 --- a/test/string_tests.c Fri Aug 09 10:24:02 2013 +0200 14.2 +++ b/test/string_tests.c Fri Aug 09 11:32:10 2013 +0200 14.3 @@ -28,7 +28,7 @@ 14.4 14.5 #include "string_tests.h" 14.6 14.7 -UCX_TEST_IMPLEMENT(test_sstr) { 14.8 +UCX_TEST(test_sstr) { 14.9 sstr_t s1 = sstr((char*)"1234"); 14.10 sstr_t s2 = sstrn((char*)"ab", 2); 14.11 14.12 @@ -40,7 +40,7 @@ 14.13 UCX_TEST_END 14.14 } 14.15 14.16 -UCX_TEST_IMPLEMENT(test_sstr_len_cat) { 14.17 +UCX_TEST(test_sstr_len_cat) { 14.18 sstr_t s1 = ST("1234"); 14.19 sstr_t s2 = ST(".:.:."); 14.20 sstr_t s3 = ST("X"); 14.21 @@ -69,7 +69,7 @@ 14.22 free(cat.ptr); 14.23 } 14.24 14.25 -UCX_TEST_IMPLEMENT(test_sstrsplit) { 14.26 +UCX_TEST(test_sstrsplit) { 14.27 14.28 const char *original = "this,is,a,csv,string"; 14.29 sstr_t test = ST("this,is,a,csv,string"); /* use copy of original here */ 14.30 @@ -193,7 +193,7 @@ 14.31 UCX_TEST_END 14.32 } 14.33 14.34 -UCX_TEST_IMPLEMENT(test_sstrtrim) { 14.35 +UCX_TEST(test_sstrtrim) { 14.36 sstr_t t1 = sstrtrim(sstr((char*)" ein test ")); 14.37 sstr_t t2 = sstrtrim(sstr((char*)"abc")); 14.38 sstr_t t3 = sstrtrim(sstr((char*)" 123"));
15.1 --- a/test/string_tests.h Fri Aug 09 10:24:02 2013 +0200 15.2 +++ b/test/string_tests.h Fri Aug 09 11:32:10 2013 +0200 15.3 @@ -36,10 +36,10 @@ 15.4 extern "C" { 15.5 #endif 15.6 15.7 -UCX_TEST_DECLARE(test_sstr); 15.8 -UCX_TEST_DECLARE(test_sstr_len_cat); 15.9 -UCX_TEST_DECLARE(test_sstrsplit); 15.10 -UCX_TEST_DECLARE(test_sstrtrim); 15.11 +UCX_TEST(test_sstr); 15.12 +UCX_TEST(test_sstr_len_cat); 15.13 +UCX_TEST(test_sstrsplit); 15.14 +UCX_TEST(test_sstrtrim); 15.15 15.16 #ifdef __cplusplus 15.17 }
16.1 --- a/ucx/test.c Fri Aug 09 10:24:02 2013 +0200 16.2 +++ b/ucx/test.c Fri Aug 09 11:32:10 2013 +0200 16.3 @@ -28,6 +28,12 @@ 16.4 16.5 #include "test.h" 16.6 16.7 + 16.8 +struct UcxTestList{ 16.9 + UcxTest test; 16.10 + UcxTestList *next; 16.11 +}; 16.12 + 16.13 UcxTestSuite* ucx_test_suite_new() { 16.14 UcxTestSuite* suite = (UcxTestSuite*) malloc(sizeof(UcxTestSuite)); 16.15 if (suite != NULL) { 16.16 @@ -35,6 +41,7 @@ 16.17 suite->failure = 0; 16.18 suite->tests = NULL; 16.19 } 16.20 + 16.21 return suite; 16.22 } 16.23
17.1 --- a/ucx/test.h Fri Aug 09 10:24:02 2013 +0200 17.2 +++ b/ucx/test.h Fri Aug 09 11:32:10 2013 +0200 17.3 @@ -26,27 +26,45 @@ 17.4 * POSSIBILITY OF SUCH DAMAGE. 17.5 */ 17.6 17.7 -/* 17.8 - * 17.9 +/** 17.10 + * @file: test.h 17.11 + * 17.12 + * UCX Test Framework. 17.13 + * 17.14 * Usage of this test framework: 17.15 * 17.16 * **** IN HEADER FILE: **** 17.17 * 17.18 - * UCX_TEST_DECLARE(function_name) 17.19 + * <pre> 17.20 + * UCX_TEST(function_name) 17.21 + * UCX_TEST_SUBROUTINE(subroutine_name, paramlist) // optional 17.22 + * </pre> 17.23 * 17.24 * **** IN SOURCE FILE: **** 17.25 + * <pre> 17.26 + * UCX_TEST_SUBROUTINE(subroutine_name, paramlist) { 17.27 + * // tests with UCX_TEST_ASSERT() 17.28 + * } 17.29 + * 17.30 + * UCX_TEST(function_name) { 17.31 + * // memory allocation and other stuff here 17.32 + * #UCX_TEST_BEGIN 17.33 + * // tests with UCX_TEST_ASSERT() and/or 17.34 + * // calls with UCX_TEST_CALL_SUBROUTINE() here 17.35 + * #UCX_TEST_END 17.36 + * // cleanup of memory here 17.37 + * } 17.38 + * </pre> 17.39 * 17.40 - * UCX_TEST_IMPLEMENT(function_name) { 17.41 - * <memory allocation and other stuff here> 17.42 - * UCX_TEST_BEGIN 17.43 - * <tests with UCX_TEST_ASSERT here> 17.44 - * UCX_TEST_END 17.45 - * <cleanup of memory here> 17.46 - * } 17.47 + * <b>Note:</b> if a test fails, a longjump is performed 17.48 + * back to the #UCX_TEST_BEGIN macro! 17.49 + * 17.50 + * <b>Attention:</b> Do not call own functions within a test, that use 17.51 + * UCX_TEST_ASSERT() macros and are not defined by using UCX_TEST_SUBROUTINE(). 17.52 + * 17.53 * 17.54 - * PLEASE NOTE: if a test fails, a longjump is performed 17.55 - * back to the UCX_TEST_BEGIN macro! 17.56 - * 17.57 + * @author Mike Becker 17.58 + * @author Olaf Wintermann 17.59 * 17.60 */ 17.61 17.62 @@ -63,50 +81,136 @@ 17.63 #endif 17.64 17.65 #ifndef __FUNCTION__ 17.66 +/** 17.67 + * Alias for the __func__ preprocessor macro. 17.68 + * Some compilers use __func__ and others use __FUNC__. We use __FUNC__ so we 17.69 + * define it for those compilers which use __func__. 17.70 + */ 17.71 #define __FUNCTION__ __func__ 17.72 #endif 17.73 17.74 +/** Type for the internal list of test cases. */ 17.75 typedef struct UcxTestList UcxTestList; 17.76 +/** Type for the UcxTestSuite. */ 17.77 typedef struct UcxTestSuite UcxTestSuite; 17.78 +/** Pointer to a test function. */ 17.79 typedef void(*UcxTest)(UcxTestSuite*,FILE*); 17.80 - 17.81 -struct UcxTestList{ 17.82 - UcxTest test; 17.83 - UcxTestList *next; 17.84 -}; 17.85 17.86 +/** 17.87 + * A test suite containing multiple test cases. 17.88 + */ 17.89 struct UcxTestSuite { 17.90 + /** The number of successful tests after the suite has been run. */ 17.91 unsigned int success; 17.92 + /** The number of failed tests after the suite has been run. */ 17.93 unsigned int failure; 17.94 + /** 17.95 + * Internal list of test cases. 17.96 + * Use ucx_test_register() to add tests to this list. 17.97 + */ 17.98 UcxTestList *tests; 17.99 }; 17.100 17.101 +/** 17.102 + * Creates a new test suite. 17.103 + * @return a new test suite 17.104 + */ 17.105 UcxTestSuite* ucx_test_suite_new(); 17.106 -void ucx_test_suite_free(UcxTestSuite*); 17.107 +/** 17.108 + * Destroys a test suite. 17.109 + * @param the test suite to destroy 17.110 + */ 17.111 +void ucx_test_suite_free(UcxTestSuite* suite); 17.112 17.113 -int ucx_test_register(UcxTestSuite*, UcxTest); 17.114 -void ucx_test_run(UcxTestSuite*, FILE*); 17.115 +/** 17.116 + * Registers a test function with the specified test suite. 17.117 + * 17.118 + * @param suite the suite, the test function shall be added to 17.119 + * @param test the test function to register 17.120 + * @return EXIT_SUCCESS on success or EXIT_FAILURE on failure 17.121 + */ 17.122 +int ucx_test_register(UcxTestSuite* suite, UcxTest test); 17.123 +/** 17.124 + * Runs a test suite and writes the test log to the specified stream. 17.125 + * @param suite the test suite to run 17.126 + * @param outstream the stream the log shall be written to 17.127 + */ 17.128 +void ucx_test_run(UcxTestSuite* suite, FILE* outstream); 17.129 17.130 -#define UCX_TEST_DECLARE(name) void name(UcxTestSuite*,FILE *) 17.131 -#define UCX_TEST_IMPLEMENT(name) void name(UcxTestSuite* _suite_,FILE *_output_) 17.132 +/** 17.133 + * Macro for a #UcxTest function header. 17.134 + * 17.135 + * Use this macro to declare and/or define an #UcxTest function. 17.136 + * 17.137 + * @param name the name of the test function 17.138 + */ 17.139 +#define UCX_TEST(name) void name(UcxTestSuite* _suite_,FILE *_output_) 17.140 17.141 +/** 17.142 + * Marks the begin of a test. 17.143 + * <b>Note:</b> Any UCX_TEST_ASSERT() calls must be performed <b>after</b> 17.144 + * #UCX_TEST_BEGIN. 17.145 + * 17.146 + * @see #UCX_TEST_END 17.147 + */ 17.148 #define UCX_TEST_BEGIN fwrite("Running ", 1, 8, _output_);\ 17.149 fwrite(__FUNCTION__, 1, strlen(__FUNCTION__), _output_);\ 17.150 fwrite("... ", 1, 4, _output_);\ 17.151 jmp_buf _env_; \ 17.152 if (!setjmp(_env_)) { 17.153 17.154 +/** 17.155 + * Checks a test assertion. 17.156 + * If the assertion is correct, the test carries on. If the assertion is not 17.157 + * correct, the specified message (terminated by a dot and a line break) is 17.158 + * written to the test suites output stream. 17.159 + * @param condition the condition to check 17.160 + * @param message the message that shall be printed out on failure 17.161 + */ 17.162 #define UCX_TEST_ASSERT(condition,message) if (!(condition)) { \ 17.163 fwrite(message".\n", 1, 2+strlen(message), _output_); \ 17.164 _suite_->failure++; \ 17.165 longjmp(_env_, 1);\ 17.166 } 17.167 17.168 +/** 17.169 + * Macro for a test subroutine function header. 17.170 + * 17.171 + * Use this to declare and/or define an subroutine that can be called by using 17.172 + * UCX_TEST_CALL_SUBROUTINE(). 17.173 + * 17.174 + * @param name the name of the subroutine 17.175 + * @param ... the parameter list 17.176 + * 17.177 + * @see UCX_TEST_CALL_SUBROUTINE() 17.178 + */ 17.179 #define UCX_TEST_SUBROUTINE(name,...) void name(UcxTestSuite* _suite_,\ 17.180 FILE *_output_, jmp_buf _env_, __VA_ARGS__) 17.181 + 17.182 +/** 17.183 + * Macro for calling a test subroutine. 17.184 + * 17.185 + * Subroutines declared with UCX_TEST_SUBROUTINE() can be called by using this 17.186 + * macro. 17.187 + * 17.188 + * <b>Note:</b> You may <b>only</b> call subroutines within a #UCX_TEST_BEGIN- 17.189 + * #UCX_TEST_END-block. 17.190 + * 17.191 + * @param name the name of the subroutine 17.192 + * @param ... the argument list 17.193 + * 17.194 + * @see UCX_TEST_SUBROUTINE() 17.195 + */ 17.196 #define UCX_TEST_CALL_SUBROUTINE(name,...) \ 17.197 name(_suite_,_output_,_env_,__VA_ARGS__); 17.198 17.199 +/** 17.200 + * Marks the end of a test. 17.201 + * <b>Note:</b> Any UCX_TEST_ASSERT() calls must be performed <b>before</b> 17.202 + * #UCX_TEST_END. 17.203 + * 17.204 + * @see #UCX_TEST_BEGIN 17.205 + */ 17.206 #define UCX_TEST_END fwrite("success.\n", 1, 9, _output_); _suite_->success++;} 17.207 17.208 #ifdef __cplusplus