1.1 --- a/test/dlist_tests.c Thu May 31 09:18:26 2012 +0200 1.2 +++ b/test/dlist_tests.c Thu May 31 12:51:22 2012 +0200 1.3 @@ -4,8 +4,9 @@ 1.4 1.5 #include "dlist_tests.h" 1.6 1.7 -UCX_TEST_BEGIN(test_ucx_dlist_append) { 1.8 +UCX_TEST_IMPLEMENT(test_ucx_dlist_append) { 1.9 UcxDlist *list = ucx_dlist_append(NULL, "Hello"); 1.10 + UCX_TEST_BEGIN 1.11 1.12 UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed") 1.13 1.14 @@ -13,46 +14,47 @@ 1.15 1.16 UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed") 1.17 UCX_TEST_ASSERT(list->next->next == NULL, "failed") 1.18 + UCX_TEST_END 1.19 1.20 ucx_dlist_free(list); 1.21 - 1.22 - UCX_TEST_END 1.23 } 1.24 1.25 -UCX_TEST_BEGIN(test_ucx_dlist_prepend) { 1.26 +UCX_TEST_IMPLEMENT(test_ucx_dlist_prepend) { 1.27 UcxDlist *list = ucx_dlist_prepend(NULL, " World!"); 1.28 + UCX_TEST_BEGIN 1.29 + 1.30 list = ucx_dlist_prepend(list, "Hello"); 1.31 1.32 UCX_TEST_ASSERT(strncmp(list->data, "Hello", 5) == 0, "failed") 1.33 UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed") 1.34 UCX_TEST_ASSERT(list->next->next == NULL, "failed") 1.35 1.36 + UCX_TEST_END 1.37 ucx_dlist_free(list); 1.38 - 1.39 - UCX_TEST_END 1.40 } 1.41 1.42 -UCX_TEST_BEGIN(test_ucx_dlist_equals) { 1.43 +UCX_TEST_IMPLEMENT(test_ucx_dlist_equals) { 1.44 UcxDlist *list = ucx_dlist_append(NULL, "Hello"); 1.45 list = ucx_dlist_append(list, " World!"); 1.46 UcxDlist *list2 = ucx_dlist_prepend(NULL, " World!"); 1.47 list2 = ucx_dlist_prepend(list2, "Hello"); 1.48 UcxDlist *list3 = ucx_dlist_prepend(NULL, " Welt!"); 1.49 list3 = ucx_dlist_prepend(list3, "Hallo"); 1.50 + UCX_TEST_BEGIN 1.51 1.52 UCX_TEST_ASSERT(ucx_dlist_equals(list, list2, cmp_string, NULL), "failed") 1.53 UCX_TEST_ASSERT(!ucx_dlist_equals(list, list3, cmp_string, NULL), "failed") 1.54 1.55 + UCX_TEST_END 1.56 ucx_dlist_free(list3); 1.57 ucx_dlist_free(list2); 1.58 ucx_dlist_free(list); 1.59 - 1.60 - UCX_TEST_END 1.61 } 1.62 1.63 -UCX_TEST_BEGIN(test_ucx_dlist_concat) { 1.64 +UCX_TEST_IMPLEMENT(test_ucx_dlist_concat) { 1.65 UcxDlist *list = ucx_dlist_append(NULL, "Hello"); 1.66 UcxDlist *list2 = ucx_dlist_prepend(NULL, " World!"); 1.67 + UCX_TEST_BEGIN 1.68 1.69 list = ucx_dlist_concat(list, list2); 1.70 1.71 @@ -60,13 +62,13 @@ 1.72 UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed") 1.73 UCX_TEST_ASSERT(list->next->next == NULL, "failed") 1.74 1.75 + UCX_TEST_END 1.76 ucx_dlist_free(list); 1.77 - 1.78 - UCX_TEST_END 1.79 } 1.80 1.81 -UCX_TEST_BEGIN(test_ucx_dlist_size) { 1.82 +UCX_TEST_IMPLEMENT(test_ucx_dlist_size) { 1.83 UcxDlist *list = ucx_dlist_append(NULL, "This "); 1.84 + UCX_TEST_BEGIN 1.85 list = ucx_dlist_append(list, "list "); 1.86 list = ucx_dlist_append(list, "has "); 1.87 list = ucx_dlist_append(list, "size "); 1.88 @@ -74,13 +76,13 @@ 1.89 1.90 UCX_TEST_ASSERT(ucx_dlist_size(list) == 5, "failed"); 1.91 1.92 + UCX_TEST_END 1.93 ucx_dlist_free(list); 1.94 - 1.95 - UCX_TEST_END 1.96 } 1.97 1.98 -UCX_TEST_BEGIN(test_ucx_dlist_first) { 1.99 +UCX_TEST_IMPLEMENT(test_ucx_dlist_first) { 1.100 UcxDlist *list = ucx_dlist_append(NULL, "Find "); 1.101 + UCX_TEST_BEGIN 1.102 list = ucx_dlist_append(list, "the "); 1.103 list = ucx_dlist_append(list, "first!"); 1.104 1.105 @@ -88,13 +90,13 @@ 1.106 1.107 UCX_TEST_ASSERT(strncmp(first, "Find ", 5) == 0, "failed"); 1.108 1.109 + UCX_TEST_END 1.110 ucx_dlist_free(list); 1.111 - 1.112 - UCX_TEST_END 1.113 } 1.114 1.115 -UCX_TEST_BEGIN(test_ucx_dlist_last) { 1.116 +UCX_TEST_IMPLEMENT(test_ucx_dlist_last) { 1.117 UcxDlist *list = ucx_dlist_append(NULL, "Find "); 1.118 + UCX_TEST_BEGIN 1.119 list = ucx_dlist_append(list, "the "); 1.120 list = ucx_dlist_append(list, "last!"); 1.121 1.122 @@ -102,13 +104,13 @@ 1.123 1.124 UCX_TEST_ASSERT(strncmp(last, "last!", 5) == 0, "failed"); 1.125 1.126 + UCX_TEST_END 1.127 ucx_dlist_free(list); 1.128 - 1.129 - UCX_TEST_END 1.130 } 1.131 1.132 -UCX_TEST_BEGIN(test_ucx_dlist_get) { 1.133 +UCX_TEST_IMPLEMENT(test_ucx_dlist_get) { 1.134 UcxDlist *list = ucx_dlist_append(NULL, "Find "); 1.135 + UCX_TEST_BEGIN 1.136 list = ucx_dlist_append(list, "the "); 1.137 list = ucx_dlist_append(list, "mid!"); 1.138 1.139 @@ -116,13 +118,13 @@ 1.140 1.141 UCX_TEST_ASSERT(strncmp(mid, "the ", 4) == 0, "failed"); 1.142 1.143 + UCX_TEST_END 1.144 ucx_dlist_free(list); 1.145 - 1.146 - UCX_TEST_END 1.147 } 1.148 1.149 -UCX_TEST_BEGIN(test_ucx_dlist_remove) { 1.150 +UCX_TEST_IMPLEMENT(test_ucx_dlist_remove) { 1.151 UcxDlist *list = ucx_dlist_append(NULL, "Hello"); 1.152 + UCX_TEST_BEGIN 1.153 list = ucx_dlist_append(list, " fucking"); 1.154 list = ucx_dlist_append(list, " World!"); 1.155 1.156 @@ -132,12 +134,11 @@ 1.157 UCX_TEST_ASSERT(strncmp(list->next->data, " World!", 7) == 0, "failed") 1.158 UCX_TEST_ASSERT(list->next->next == NULL, "failed") 1.159 1.160 + UCX_TEST_END 1.161 ucx_dlist_free(list); 1.162 - 1.163 - UCX_TEST_END 1.164 } 1.165 1.166 -UCX_TEST_BEGIN(test_ucx_dlist_clone) { 1.167 +UCX_TEST_IMPLEMENT(test_ucx_dlist_clone) { 1.168 1.169 char *hello = (char*)malloc(6); 1.170 char *world = (char*)malloc(8); 1.171 @@ -149,11 +150,13 @@ 1.172 list = ucx_dlist_append(list, world); 1.173 1.174 UcxDlist *copy = ucx_dlist_clone(list, copy_string, NULL); 1.175 + UCX_TEST_BEGIN 1.176 1.177 UCX_TEST_ASSERT(ucx_dlist_equals(list, copy, cmp_string, NULL), "failed") 1.178 UCX_TEST_ASSERT(hello != copy->data, "first element is no copy") 1.179 UCX_TEST_ASSERT(world != copy->next->data, "second element is no copy") 1.180 1.181 + UCX_TEST_END 1.182 free(copy->next->data); 1.183 free(copy->data); 1.184 1.185 @@ -161,6 +164,4 @@ 1.186 free(hello); 1.187 ucx_dlist_free(list); 1.188 ucx_dlist_free(copy); 1.189 - 1.190 - UCX_TEST_END 1.191 }