Tue, 05 Oct 2021 13:03:45 +0200
add special linked list implementation for storing pointers
1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright 2021 Mike Becker, Olaf Wintermann All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
29 #include "cx/linked_list.h"
30 #include "test_config.h"
31 #include "util_allocator.h"
33 int cmp_int(int const *l, int const *r) {
34 int left = *l, right = *r;
35 return left == right ? 0 : (left < right ? -1 : 1);
36 }
38 void test_linked_list_at(void) {
39 struct node {
40 void *next;
41 void *prev;
42 };
43 const ptrdiff_t loc_prev = offsetof(struct node, prev);
44 const ptrdiff_t loc_next = offsetof(struct node, next);
46 struct node a, b, c, d;
47 a.prev = NULL;
48 a.next = &b;
49 b.prev = &a;
50 b.next = &c;
51 c.prev = &b;
52 c.next = &d;
53 d.prev = &c;
54 d.next = NULL;
56 CU_ASSERT_PTR_EQUAL(cx_linked_list_at(&a, 0, loc_next, 0), &a)
57 CU_ASSERT_PTR_EQUAL(cx_linked_list_at(&a, 0, loc_next, 1), &b)
58 CU_ASSERT_PTR_EQUAL(cx_linked_list_at(&a, 0, loc_next, 2), &c)
59 CU_ASSERT_PTR_EQUAL(cx_linked_list_at(&a, 0, loc_next, 3), &d)
60 CU_ASSERT_PTR_NULL(cx_linked_list_at(&a, 0, loc_next, 4))
62 CU_ASSERT_PTR_EQUAL(cx_linked_list_at(&b, 1, loc_prev, 0), &a)
63 CU_ASSERT_PTR_EQUAL(cx_linked_list_at(&b, 1, loc_next, 1), &b)
64 CU_ASSERT_PTR_EQUAL(cx_linked_list_at(&b, 1, loc_next, 2), &c)
65 CU_ASSERT_PTR_EQUAL(cx_linked_list_at(&b, 1, loc_next, 3), &d)
66 CU_ASSERT_PTR_NULL(cx_linked_list_at(&b, 1, loc_next, 4))
68 CU_ASSERT_PTR_EQUAL(cx_linked_list_at(&d, 3, loc_prev, 0), &a)
69 CU_ASSERT_PTR_EQUAL(cx_linked_list_at(&d, 3, loc_prev, 1), &b)
70 }
72 void test_linked_list_add(void) {
73 struct node {
74 void *prev;
75 void *next;
76 };
78 struct node nodes[4];
80 // test with begin, end / prev, next
81 memset(nodes, 0, 4 * sizeof(struct node));
82 void *begin = NULL;
83 void *end = NULL;
85 ptrdiff_t loc_prev = offsetof(struct node, prev);
86 ptrdiff_t loc_next = offsetof(struct node, next);
88 cx_linked_list_add(&begin, &end, loc_prev, loc_next, &nodes[0]);
89 CU_ASSERT_PTR_EQUAL(begin, &nodes[0])
90 CU_ASSERT_PTR_EQUAL(end, &nodes[0])
91 CU_ASSERT_PTR_EQUAL(nodes[0].prev, NULL)
92 CU_ASSERT_PTR_EQUAL(nodes[0].next, NULL)
94 cx_linked_list_add(&begin, &end, loc_prev, loc_next, &nodes[1]);
95 CU_ASSERT_PTR_EQUAL(begin, &nodes[0])
96 CU_ASSERT_PTR_EQUAL(end, &nodes[1])
97 CU_ASSERT_PTR_EQUAL(nodes[0].next, &nodes[1])
98 CU_ASSERT_PTR_EQUAL(nodes[1].prev, &nodes[0])
100 // test with begin only / prev, next
101 memset(nodes, 0, 4 * sizeof(struct node));
102 begin = NULL;
103 end = NULL;
105 cx_linked_list_add(&begin, NULL, loc_prev, loc_next, &nodes[0]);
106 CU_ASSERT_PTR_EQUAL(begin, &nodes[0])
107 cx_linked_list_add(&begin, NULL, loc_prev, loc_next, &nodes[1]);
108 CU_ASSERT_PTR_EQUAL(begin, &nodes[0])
109 CU_ASSERT_PTR_EQUAL(nodes[0].next, &nodes[1])
110 CU_ASSERT_PTR_EQUAL(nodes[1].prev, &nodes[0])
112 cx_linked_list_add(&begin, NULL, loc_prev, loc_next, &nodes[2]);
113 CU_ASSERT_PTR_EQUAL(nodes[1].next, &nodes[2])
114 CU_ASSERT_PTR_EQUAL(nodes[2].prev, &nodes[1])
116 // test with begin, end / next
117 memset(nodes, 0, 4 * sizeof(struct node));
118 begin = NULL;
119 end = NULL;
121 cx_linked_list_add(&begin, &end, -1, loc_next, &nodes[0]);
122 CU_ASSERT_PTR_EQUAL(begin, &nodes[0])
123 CU_ASSERT_PTR_EQUAL(end, &nodes[0])
124 cx_linked_list_add(&begin, &end, -1, loc_next, &nodes[1]);
125 CU_ASSERT_PTR_EQUAL(end, &nodes[1])
126 CU_ASSERT_PTR_EQUAL(nodes[0].next, &nodes[1])
127 CU_ASSERT_PTR_NULL(nodes[1].prev)
128 }
130 void test_linked_list_last(void) {
131 CU_ASSERT_PTR_NULL(cx_linked_list_last(NULL, -1))
132 CU_ASSERT_PTR_NULL(cx_linked_list_last(NULL, 0))
134 struct node {
135 int data;
136 void *next;
137 };
138 ptrdiff_t loc = offsetof(struct node, next);
140 struct node third = {3, NULL};
141 struct node second = {2, &third};
142 struct node first = {1, &second};
144 CU_ASSERT_PTR_EQUAL(cx_linked_list_last(&first, loc), &third)
145 CU_ASSERT_PTR_EQUAL(cx_linked_list_last(&second, loc), &third)
146 CU_ASSERT_PTR_EQUAL(cx_linked_list_last(&third, loc), &third)
147 }
150 void test_hl_linked_list_create(void) {
151 cxTestingAllocatorReset();
153 CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int));
155 CU_ASSERT_EQUAL(list->size, 0)
156 CU_ASSERT_EQUAL(list->capacity, (size_t) -1)
157 CU_ASSERT_PTR_EQUAL(list->allocator, cxTestingAllocator)
158 CU_ASSERT_EQUAL(list->itemsize, sizeof(int))
159 CU_ASSERT_PTR_EQUAL(list->cmpfunc, cmp_int)
161 cxLinkedListDestroy(list);
162 CU_ASSERT_TRUE(cxTestingAllocatorVerify())
163 }
165 void test_hl_linked_list_add(void) {
166 cxTestingAllocatorReset();
168 int data;
169 CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int));
171 data = 5;
172 CU_ASSERT_EQUAL(cxListAdd(list, &data), 0)
173 data = 47;
174 CU_ASSERT_EQUAL(cxListAdd(list, &data), 0)
175 data = 13;
176 CU_ASSERT_EQUAL(cxListAdd(list, &data), 0)
178 CU_ASSERT_EQUAL(list->size, 3)
179 CU_ASSERT_TRUE(list->capacity >= list->size)
181 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 0), 5)
182 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 1), 47)
183 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 2), 13)
185 cxLinkedListDestroy(list);
186 CU_ASSERT_TRUE(cxTestingAllocatorVerify())
187 }
189 void test_hl_linked_list_last(void) {
190 cxTestingAllocatorReset();
192 int data;
193 CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int));
195 CU_ASSERT_PTR_NULL(cxListLast(list))
197 data = 5;
198 CU_ASSERT_EQUAL(cxListAdd(list, &data), 0)
199 CU_ASSERT_EQUAL(*(int *) cxListLast(list), 5)
201 data = 47;
202 CU_ASSERT_EQUAL(cxListAdd(list, &data), 0)
203 CU_ASSERT_EQUAL(*(int *) cxListLast(list), 47)
205 cxLinkedListDestroy(list);
206 CU_ASSERT_TRUE(cxTestingAllocatorVerify())
207 }
209 void test_hl_linked_list_insert(void) {
210 cxTestingAllocatorReset();
212 int data;
213 CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int));
215 data = 5;
216 CU_ASSERT_NOT_EQUAL(cxListInsert(list, 1, &data), 0)
217 CU_ASSERT_EQUAL(list->size, 0)
218 CU_ASSERT_EQUAL(cxListInsert(list, 0, &data), 0)
219 CU_ASSERT_EQUAL(list->size, 1)
220 data = 47;
221 CU_ASSERT_EQUAL(cxListInsert(list, 0, &data), 0)
222 CU_ASSERT_EQUAL(list->size, 2)
223 data = 13;
224 CU_ASSERT_EQUAL(cxListInsert(list, 1, &data), 0)
225 CU_ASSERT_EQUAL(list->size, 3)
226 data = 42;
227 CU_ASSERT_EQUAL(cxListInsert(list, 3, &data), 0)
229 CU_ASSERT_EQUAL(list->size, 4)
230 CU_ASSERT_TRUE(list->capacity >= list->size)
232 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 0), 47)
233 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 1), 13)
234 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 2), 5)
235 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 3), 42)
237 cxLinkedListDestroy(list);
238 CU_ASSERT_TRUE(cxTestingAllocatorVerify())
239 }
241 void test_hl_linked_list_remove(void) {
242 cxTestingAllocatorReset();
244 int data;
245 CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int));
247 data = 5;
248 cxListAdd(list, &data);
249 data = 47;
250 cxListAdd(list, &data);
251 data = 42;
252 cxListAdd(list, &data);
253 data = 13;
254 cxListAdd(list, &data);
256 CU_ASSERT_EQUAL(list->size, 4)
257 CU_ASSERT_TRUE(list->capacity >= list->size)
259 CU_ASSERT_NOT_EQUAL(cxListRemove(list, 4), 0)
261 CU_ASSERT_EQUAL(cxListRemove(list, 2), 0)
262 CU_ASSERT_EQUAL(list->size, 3)
263 CU_ASSERT_TRUE(list->capacity >= list->size)
264 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 0), 5)
265 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 1), 47)
266 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 2), 13)
268 CU_ASSERT_EQUAL(cxListRemove(list, 0), 0)
269 CU_ASSERT_EQUAL(list->size, 2)
270 CU_ASSERT_TRUE(list->capacity >= list->size)
271 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 0), 47)
272 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 1), 13)
274 CU_ASSERT_EQUAL(cxListRemove(list, 1), 0)
275 CU_ASSERT_EQUAL(list->size, 1)
276 CU_ASSERT_TRUE(list->capacity >= list->size)
277 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 0), 47)
279 CU_ASSERT_EQUAL(cxListRemove(list, 0), 0)
280 CU_ASSERT_EQUAL(list->size, 0)
281 CU_ASSERT_TRUE(list->capacity >= list->size)
283 CU_ASSERT_NOT_EQUAL(cxListRemove(list, 0), 0)
285 cxLinkedListDestroy(list);
286 CU_ASSERT_TRUE(cxTestingAllocatorVerify())
287 }
289 void test_hl_linked_list_find(void) {
290 cxTestingAllocatorReset();
292 int data, criteria;
293 CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int));
295 data = 5;
296 cxListAdd(list, &data);
297 data = 47;
298 cxListAdd(list, &data);
299 data = 13;
300 cxListAdd(list, &data);
302 CU_ASSERT_EQUAL(list->size, 3)
303 CU_ASSERT_TRUE(list->capacity >= list->size)
305 criteria = 5;
306 CU_ASSERT_EQUAL(cxListFind(list, &criteria), 0)
307 criteria = 47;
308 CU_ASSERT_EQUAL(cxListFind(list, &criteria), 1)
309 criteria = 13;
310 CU_ASSERT_EQUAL(cxListFind(list, &criteria), 2)
311 criteria = 9000;
312 CU_ASSERT_EQUAL(cxListFind(list, &criteria), 3)
313 criteria = -5;
314 CU_ASSERT_EQUAL(cxListFind(list, &criteria), 3)
316 cxLinkedListDestroy(list);
317 CU_ASSERT_TRUE(cxTestingAllocatorVerify())
318 }
320 void test_hl_ptr_linked_list_create(void) {
321 cxTestingAllocatorReset();
323 CxList list = cxPointerLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int);
325 CU_ASSERT_EQUAL(list->size, 0)
326 CU_ASSERT_EQUAL(list->capacity, (size_t) -1)
327 CU_ASSERT_PTR_EQUAL(list->allocator, cxTestingAllocator)
328 CU_ASSERT_EQUAL(list->itemsize, sizeof(void *))
329 CU_ASSERT_PTR_EQUAL(list->cmpfunc, cmp_int)
331 cxLinkedListDestroy(list);
332 CU_ASSERT_TRUE(cxTestingAllocatorVerify())
333 }
335 void test_hl_ptr_linked_list_add(void) {
336 cxTestingAllocatorReset();
338 CxList list = cxPointerLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int);
340 int a = 5, b = 47, c = 13;
342 CU_ASSERT_EQUAL(cxListAdd(list, &a), 0)
343 CU_ASSERT_EQUAL(cxListAdd(list, &b), 0)
344 CU_ASSERT_EQUAL(cxListAdd(list, &c), 0)
346 CU_ASSERT_EQUAL(list->size, 3)
347 CU_ASSERT_TRUE(list->capacity >= list->size)
349 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 0), 5)
350 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 1), 47)
351 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 2), 13)
353 a = 9;
354 b = 10;
355 c = 11;
357 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 0), 9)
358 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 1), 10)
359 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 2), 11)
361 cxLinkedListDestroy(list);
362 CU_ASSERT_TRUE(cxTestingAllocatorVerify())
363 }
365 void test_hl_ptr_linked_list_last(void) {
366 cxTestingAllocatorReset();
368 CxList list = cxPointerLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int);
369 CU_ASSERT_PTR_NULL(cxListLast(list))
371 int a = 5, b = 47;
373 CU_ASSERT_EQUAL(cxListAdd(list, &a), 0)
374 CU_ASSERT_EQUAL(*(int *) cxListLast(list), 5)
375 CU_ASSERT_EQUAL(cxListAdd(list, &b), 0)
376 CU_ASSERT_EQUAL(*(int *) cxListLast(list), 47)
378 cxLinkedListDestroy(list);
379 CU_ASSERT_TRUE(cxTestingAllocatorVerify())
380 }
382 void test_hl_ptr_linked_list_insert(void) {
383 cxTestingAllocatorReset();
385 CxList list = cxPointerLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int);
387 int a = 5, b = 47, c = 13, d = 42;
389 CU_ASSERT_NOT_EQUAL(cxListInsert(list, 1, &a), 0)
390 CU_ASSERT_EQUAL(list->size, 0)
391 CU_ASSERT_EQUAL(cxListInsert(list, 0, &a), 0)
392 CU_ASSERT_EQUAL(list->size, 1)
393 CU_ASSERT_EQUAL(cxListInsert(list, 0, &b), 0)
394 CU_ASSERT_EQUAL(list->size, 2)
395 CU_ASSERT_EQUAL(cxListInsert(list, 1, &c), 0)
396 CU_ASSERT_EQUAL(list->size, 3)
397 CU_ASSERT_EQUAL(cxListInsert(list, 3, &d), 0)
399 CU_ASSERT_EQUAL(list->size, 4)
400 CU_ASSERT_TRUE(list->capacity >= list->size)
402 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 0), 47)
403 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 1), 13)
404 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 2), 5)
405 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 3), 42)
407 cxLinkedListDestroy(list);
408 CU_ASSERT_TRUE(cxTestingAllocatorVerify())
409 }
411 void test_hl_ptr_linked_list_remove(void) {
412 cxTestingAllocatorReset();
414 int a = 5, b = 47, c = 42, d = 13;
415 CxList list = cxPointerLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int);
417 cxListAdd(list, &a);
418 cxListAdd(list, &b);
419 cxListAdd(list, &c);
420 cxListAdd(list, &d);
422 CU_ASSERT_EQUAL(list->size, 4)
423 CU_ASSERT_TRUE(list->capacity >= list->size)
425 CU_ASSERT_NOT_EQUAL(cxListRemove(list, 4), 0)
427 CU_ASSERT_EQUAL(cxListRemove(list, 2), 0)
428 CU_ASSERT_EQUAL(list->size, 3)
429 CU_ASSERT_TRUE(list->capacity >= list->size)
430 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 0), 5)
431 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 1), 47)
432 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 2), 13)
434 CU_ASSERT_EQUAL(cxListRemove(list, 0), 0)
435 CU_ASSERT_EQUAL(list->size, 2)
436 CU_ASSERT_TRUE(list->capacity >= list->size)
437 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 0), 47)
438 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 1), 13)
440 CU_ASSERT_EQUAL(cxListRemove(list, 1), 0)
441 CU_ASSERT_EQUAL(list->size, 1)
442 CU_ASSERT_TRUE(list->capacity >= list->size)
443 CU_ASSERT_EQUAL(*(int *) cxListAt(list, 0), 47)
445 CU_ASSERT_EQUAL(cxListRemove(list, 0), 0)
446 CU_ASSERT_EQUAL(list->size, 0)
447 CU_ASSERT_TRUE(list->capacity >= list->size)
449 CU_ASSERT_NOT_EQUAL(cxListRemove(list, 0), 0)
451 cxLinkedListDestroy(list);
452 CU_ASSERT_TRUE(cxTestingAllocatorVerify())
453 }
455 void test_hl_ptr_linked_list_find(void) {
456 cxTestingAllocatorReset();
458 int a = 5, b = 47, c = 13, criteria;
459 CxList list = cxPointerLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int);
461 cxListAdd(list, &a);
462 cxListAdd(list, &b);
463 cxListAdd(list, &c);
465 CU_ASSERT_EQUAL(list->size, 3)
466 CU_ASSERT_TRUE(list->capacity >= list->size)
468 criteria = 5;
469 CU_ASSERT_EQUAL(cxListFind(list, &criteria), 0)
470 criteria = 47;
471 CU_ASSERT_EQUAL(cxListFind(list, &criteria), 1)
472 criteria = 13;
473 CU_ASSERT_EQUAL(cxListFind(list, &criteria), 2)
474 criteria = 9000;
475 CU_ASSERT_EQUAL(cxListFind(list, &criteria), 3)
476 criteria = -5;
477 CU_ASSERT_EQUAL(cxListFind(list, &criteria), 3)
478 b = -5;
479 CU_ASSERT_EQUAL(cxListFind(list, &criteria), 1)
481 cxLinkedListDestroy(list);
482 CU_ASSERT_TRUE(cxTestingAllocatorVerify())
483 }
485 int main() {
486 CU_pSuite suite = NULL;
488 if (CUE_SUCCESS != CU_initialize_registry()) {
489 return CU_get_error();
490 }
492 suite = CU_add_suite("low level linked list", NULL, NULL);
494 cu_add_test(suite, test_linked_list_at);
495 cu_add_test(suite, test_linked_list_add);
496 cu_add_test(suite, test_linked_list_last);
498 suite = CU_add_suite("high level linked list", NULL, NULL);
500 cu_add_test(suite, test_hl_linked_list_create);
501 cu_add_test(suite, test_hl_linked_list_add);
502 cu_add_test(suite, test_hl_linked_list_last);
503 cu_add_test(suite, test_hl_linked_list_insert);
504 cu_add_test(suite, test_hl_linked_list_remove);
505 cu_add_test(suite, test_hl_linked_list_find);
507 suite = CU_add_suite("high level pointer linked list", NULL, NULL);
509 cu_add_test(suite, test_hl_ptr_linked_list_create);
510 cu_add_test(suite, test_hl_ptr_linked_list_add);
511 cu_add_test(suite, test_hl_ptr_linked_list_last);
512 cu_add_test(suite, test_hl_ptr_linked_list_insert);
513 cu_add_test(suite, test_hl_ptr_linked_list_remove);
514 cu_add_test(suite, test_hl_ptr_linked_list_find);
516 CU_basic_set_mode(UCX_CU_BRM);
518 int exitcode;
519 if (CU_basic_run_tests()) {
520 exitcode = CU_get_error();
521 } else {
522 exitcode = CU_get_number_of_failures() == 0 ? 0 : 1;
523 }
524 CU_cleanup_registry();
525 return exitcode;
526 }