test/list_tests.c

changeset 134
4d320dc3a7af
parent 123
7fb0f74517c5
child 162
52dfe5f4ecd7
equal deleted inserted replaced
133:0a70e0d36949 134:4d320dc3a7af
27 */ 27 */
28 28
29 #include "list_tests.h" 29 #include "list_tests.h"
30 #include "ucx/utils.h" 30 #include "ucx/utils.h"
31 31
32 UCX_TEST_IMPLEMENT(test_ucx_list_append) { 32 UCX_TEST(test_ucx_list_append) {
33 UcxList *list = ucx_list_append(NULL, (void*)"Hello"); 33 UcxList *list = ucx_list_append(NULL, (void*)"Hello");
34 UCX_TEST_BEGIN 34 UCX_TEST_BEGIN
35 35
36 UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0, 36 UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
37 "failed"); 37 "failed");
44 UCX_TEST_END 44 UCX_TEST_END
45 45
46 ucx_list_free(list); 46 ucx_list_free(list);
47 } 47 }
48 48
49 UCX_TEST_IMPLEMENT(test_ucx_list_prepend) { 49 UCX_TEST(test_ucx_list_prepend) {
50 UcxList *list = ucx_list_prepend(NULL, (void*)" World!"); 50 UcxList *list = ucx_list_prepend(NULL, (void*)" World!");
51 UCX_TEST_BEGIN 51 UCX_TEST_BEGIN
52 52
53 list = ucx_list_prepend(list, (void*)"Hello"); 53 list = ucx_list_prepend(list, (void*)"Hello");
54 54
60 60
61 UCX_TEST_END 61 UCX_TEST_END
62 ucx_list_free(list); 62 ucx_list_free(list);
63 } 63 }
64 64
65 UCX_TEST_IMPLEMENT(test_ucx_list_equals) { 65 UCX_TEST(test_ucx_list_equals) {
66 UcxList *list = ucx_list_append(NULL, (void*)"Hello"); 66 UcxList *list = ucx_list_append(NULL, (void*)"Hello");
67 list = ucx_list_append(list, (void*)" World!"); 67 list = ucx_list_append(list, (void*)" World!");
68 UcxList *list2 = ucx_list_prepend(NULL, (void*)" World!"); 68 UcxList *list2 = ucx_list_prepend(NULL, (void*)" World!");
69 list2 = ucx_list_prepend(list2, (void*)"Hello"); 69 list2 = ucx_list_prepend(list2, (void*)"Hello");
70 UcxList *list3 = ucx_list_prepend(NULL, (void*)" Welt!"); 70 UcxList *list3 = ucx_list_prepend(NULL, (void*)" Welt!");
78 ucx_list_free(list3); 78 ucx_list_free(list3);
79 ucx_list_free(list2); 79 ucx_list_free(list2);
80 ucx_list_free(list); 80 ucx_list_free(list);
81 } 81 }
82 82
83 UCX_TEST_IMPLEMENT(test_ucx_list_concat) { 83 UCX_TEST(test_ucx_list_concat) {
84 UcxList *list = ucx_list_append(NULL, (void*)"Hello"); 84 UcxList *list = ucx_list_append(NULL, (void*)"Hello");
85 UcxList *list2 = ucx_list_prepend(NULL, (void*)" World!"); 85 UcxList *list2 = ucx_list_prepend(NULL, (void*)" World!");
86 UCX_TEST_BEGIN 86 UCX_TEST_BEGIN
87 87
88 list = ucx_list_concat(list, list2); 88 list = ucx_list_concat(list, list2);
95 95
96 UCX_TEST_END 96 UCX_TEST_END
97 ucx_list_free(list); 97 ucx_list_free(list);
98 } 98 }
99 99
100 UCX_TEST_IMPLEMENT(test_ucx_list_size) { 100 UCX_TEST(test_ucx_list_size) {
101 UcxList *list = ucx_list_append(NULL, (void*)"This "); 101 UcxList *list = ucx_list_append(NULL, (void*)"This ");
102 list = ucx_list_append(list, (void*)"list "); 102 list = ucx_list_append(list, (void*)"list ");
103 list = ucx_list_append(list, (void*)"has "); 103 list = ucx_list_append(list, (void*)"has ");
104 list = ucx_list_append(list, (void*)"size "); 104 list = ucx_list_append(list, (void*)"size ");
105 list = ucx_list_append(list, (void*)"5!"); 105 list = ucx_list_append(list, (void*)"5!");
110 110
111 UCX_TEST_END 111 UCX_TEST_END
112 ucx_list_free(list); 112 ucx_list_free(list);
113 } 113 }
114 114
115 UCX_TEST_IMPLEMENT(test_ucx_list_first) { 115 UCX_TEST(test_ucx_list_first) {
116 UcxList *list = ucx_list_append(NULL, (void*)"Find "); 116 UcxList *list = ucx_list_append(NULL, (void*)"Find ");
117 list = ucx_list_append(list, (void*)"the "); 117 list = ucx_list_append(list, (void*)"the ");
118 list = ucx_list_append(list, (void*)"first!"); 118 list = ucx_list_append(list, (void*)"first!");
119 119
120 UCX_TEST_BEGIN 120 UCX_TEST_BEGIN
125 125
126 UCX_TEST_END 126 UCX_TEST_END
127 ucx_list_free(list); 127 ucx_list_free(list);
128 } 128 }
129 129
130 UCX_TEST_IMPLEMENT(test_ucx_list_last) { 130 UCX_TEST(test_ucx_list_last) {
131 UcxList *list = ucx_list_append(NULL, (void*)"Find "); 131 UcxList *list = ucx_list_append(NULL, (void*)"Find ");
132 list = ucx_list_append(list, (void*)"the "); 132 list = ucx_list_append(list, (void*)"the ");
133 list = ucx_list_append(list, (void*)"last!"); 133 list = ucx_list_append(list, (void*)"last!");
134 134
135 UCX_TEST_BEGIN 135 UCX_TEST_BEGIN
140 140
141 UCX_TEST_END 141 UCX_TEST_END
142 ucx_list_free(list); 142 ucx_list_free(list);
143 } 143 }
144 144
145 UCX_TEST_IMPLEMENT(test_ucx_list_get) { 145 UCX_TEST(test_ucx_list_get) {
146 UcxList *list = ucx_list_append(NULL, (void*)"Find "); 146 UcxList *list = ucx_list_append(NULL, (void*)"Find ");
147 list = ucx_list_append(list, (void*)"the "); 147 list = ucx_list_append(list, (void*)"the ");
148 list = ucx_list_append(list, (void*)"mid!"); 148 list = ucx_list_append(list, (void*)"mid!");
149 149
150 UCX_TEST_BEGIN 150 UCX_TEST_BEGIN
155 155
156 UCX_TEST_END 156 UCX_TEST_END
157 ucx_list_free(list); 157 ucx_list_free(list);
158 } 158 }
159 159
160 UCX_TEST_IMPLEMENT(test_ucx_list_indexof) { 160 UCX_TEST(test_ucx_list_indexof) {
161 UcxList *list = ucx_list_append(NULL, (void*)"Find "); 161 UcxList *list = ucx_list_append(NULL, (void*)"Find ");
162 list = ucx_list_append(list, (void*)"the "); 162 list = ucx_list_append(list, (void*)"the ");
163 list = ucx_list_append(list, (void*)"mid!"); 163 list = ucx_list_append(list, (void*)"mid!");
164 164
165 UCX_TEST_BEGIN 165 UCX_TEST_BEGIN
175 175
176 UCX_TEST_END 176 UCX_TEST_END
177 ucx_list_free(list); 177 ucx_list_free(list);
178 } 178 }
179 179
180 UCX_TEST_IMPLEMENT(test_ucx_list_find) { 180 UCX_TEST(test_ucx_list_find) {
181 UcxList *l = ucx_list_append(NULL, (void*)"find "); 181 UcxList *l = ucx_list_append(NULL, (void*)"find ");
182 l = ucx_list_append(l, (void*)"some "); 182 l = ucx_list_append(l, (void*)"some ");
183 l = ucx_list_append(l, (void*)"string!"); 183 l = ucx_list_append(l, (void*)"string!");
184 184
185 UCX_TEST_BEGIN 185 UCX_TEST_BEGIN
191 191
192 UCX_TEST_END 192 UCX_TEST_END
193 ucx_list_free(l); 193 ucx_list_free(l);
194 } 194 }
195 195
196 UCX_TEST_IMPLEMENT(test_ucx_list_contains) { 196 UCX_TEST(test_ucx_list_contains) {
197 UcxList *l = ucx_list_append(NULL, (void*)"Contains "); 197 UcxList *l = ucx_list_append(NULL, (void*)"Contains ");
198 l = ucx_list_append(l, (void*)"a "); 198 l = ucx_list_append(l, (void*)"a ");
199 l = ucx_list_append(l, (void*)"string!"); 199 l = ucx_list_append(l, (void*)"string!");
200 200
201 UCX_TEST_BEGIN 201 UCX_TEST_BEGIN
207 207
208 UCX_TEST_END 208 UCX_TEST_END
209 ucx_list_free(l); 209 ucx_list_free(l);
210 } 210 }
211 211
212 UCX_TEST_IMPLEMENT(test_ucx_list_remove) { 212 UCX_TEST(test_ucx_list_remove) {
213 UcxList *list = ucx_list_append(NULL, (void*)"Hello"); 213 UcxList *list = ucx_list_append(NULL, (void*)"Hello");
214 list = ucx_list_append(list, (void*)" fucking"); 214 list = ucx_list_append(list, (void*)" fucking");
215 list = ucx_list_append(list, (void*)" World!"); 215 list = ucx_list_append(list, (void*)" World!");
216 216
217 UCX_TEST_BEGIN 217 UCX_TEST_BEGIN
226 226
227 UCX_TEST_END 227 UCX_TEST_END
228 ucx_list_free(list); 228 ucx_list_free(list);
229 } 229 }
230 230
231 UCX_TEST_IMPLEMENT(test_ucx_list_clone) { 231 UCX_TEST(test_ucx_list_clone) {
232 232
233 char *hello = (char*)malloc(6); 233 char *hello = (char*)malloc(6);
234 char *world = (char*)malloc(8); 234 char *world = (char*)malloc(8);
235 235
236 memcpy(hello, "Hello", 6); 236 memcpy(hello, "Hello", 6);
254 free(hello); 254 free(hello);
255 ucx_list_free(list); 255 ucx_list_free(list);
256 ucx_list_free(copy); 256 ucx_list_free(copy);
257 } 257 }
258 258
259 UCX_TEST_IMPLEMENT(test_ucx_list_sort) { 259 UCX_TEST(test_ucx_list_sort) {
260 UcxList *list = ucx_list_append(NULL, (void*)"this"); 260 UcxList *list = ucx_list_append(NULL, (void*)"this");
261 list = ucx_list_append(list, (void*)"is"); 261 list = ucx_list_append(list, (void*)"is");
262 list = ucx_list_append(list, (void*)"a"); 262 list = ucx_list_append(list, (void*)"a");
263 list = ucx_list_append(list, (void*)"test"); 263 list = ucx_list_append(list, (void*)"test");
264 list = ucx_list_append(list, (void*)"for"); 264 list = ucx_list_append(list, (void*)"for");

mercurial