Tue, 05 Oct 2021 12:16:50 +0200
remove obsolete config from Doxyfile
390 | 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 | */ | |
28 | ||
398
8d506ed6c1c0
adds first draft for linked list implementation
Mike Becker <universe@uap-core.de>
parents:
390
diff
changeset
|
29 | #include "cx/linked_list.h" |
411
2842f729caab
add first test suite to test_linked_list.c
Mike Becker <universe@uap-core.de>
parents:
398
diff
changeset
|
30 | #include "test_config.h" |
422
afd87df80b13
add utility to verify allocations
Mike Becker <universe@uap-core.de>
parents:
413
diff
changeset
|
31 | #include "util_allocator.h" |
398
8d506ed6c1c0
adds first draft for linked list implementation
Mike Becker <universe@uap-core.de>
parents:
390
diff
changeset
|
32 | |
412
af766caea48d
removes stupid high level wrapper for linked lists + adds test for cxLinkedListCreate
Mike Becker <universe@uap-core.de>
parents:
411
diff
changeset
|
33 | int cmp_int(int const *l, int const *r) { |
af766caea48d
removes stupid high level wrapper for linked lists + adds test for cxLinkedListCreate
Mike Becker <universe@uap-core.de>
parents:
411
diff
changeset
|
34 | int left = *l, right = *r; |
af766caea48d
removes stupid high level wrapper for linked lists + adds test for cxLinkedListCreate
Mike Becker <universe@uap-core.de>
parents:
411
diff
changeset
|
35 | return left == right ? 0 : (left < right ? -1 : 1); |
af766caea48d
removes stupid high level wrapper for linked lists + adds test for cxLinkedListCreate
Mike Becker <universe@uap-core.de>
parents:
411
diff
changeset
|
36 | } |
af766caea48d
removes stupid high level wrapper for linked lists + adds test for cxLinkedListCreate
Mike Becker <universe@uap-core.de>
parents:
411
diff
changeset
|
37 | |
438
cd3069757010
add function cx_linked_list_at()
Mike Becker <universe@uap-core.de>
parents:
435
diff
changeset
|
38 | void test_linked_list_at(void) { |
cd3069757010
add function cx_linked_list_at()
Mike Becker <universe@uap-core.de>
parents:
435
diff
changeset
|
39 | struct node { |
cd3069757010
add function cx_linked_list_at()
Mike Becker <universe@uap-core.de>
parents:
435
diff
changeset
|
40 | void *next; |
cd3069757010
add function cx_linked_list_at()
Mike Becker <universe@uap-core.de>
parents:
435
diff
changeset
|
41 | void *prev; |
cd3069757010
add function cx_linked_list_at()
Mike Becker <universe@uap-core.de>
parents:
435
diff
changeset
|
42 | }; |
cd3069757010
add function cx_linked_list_at()
Mike Becker <universe@uap-core.de>
parents:
435
diff
changeset
|
43 | const ptrdiff_t loc_prev = offsetof(struct node, prev); |
cd3069757010
add function cx_linked_list_at()
Mike Becker <universe@uap-core.de>
parents:
435
diff
changeset
|
44 | const ptrdiff_t loc_next = offsetof(struct node, next); |
cd3069757010
add function cx_linked_list_at()
Mike Becker <universe@uap-core.de>
parents:
435
diff
changeset
|
45 | |
cd3069757010
add function cx_linked_list_at()
Mike Becker <universe@uap-core.de>
parents:
435
diff
changeset
|
46 | struct node a, b, c, d; |
cd3069757010
add function cx_linked_list_at()
Mike Becker <universe@uap-core.de>
parents:
435
diff
changeset
|
47 | a.prev = NULL; |
cd3069757010
add function cx_linked_list_at()
Mike Becker <universe@uap-core.de>
parents:
435
diff
changeset
|
48 | a.next = &b; |
cd3069757010
add function cx_linked_list_at()
Mike Becker <universe@uap-core.de>
parents:
435
diff
changeset
|
49 | b.prev = &a; |
cd3069757010
add function cx_linked_list_at()
Mike Becker <universe@uap-core.de>
parents:
435
diff
changeset
|
50 | b.next = &c; |
cd3069757010
add function cx_linked_list_at()
Mike Becker <universe@uap-core.de>
parents:
435
diff
changeset
|
51 | c.prev = &b; |
cd3069757010
add function cx_linked_list_at()
Mike Becker <universe@uap-core.de>
parents:
435
diff
changeset
|
52 | c.next = &d; |
cd3069757010
add function cx_linked_list_at()
Mike Becker <universe@uap-core.de>
parents:
435
diff
changeset
|
53 | d.prev = &c; |
cd3069757010
add function cx_linked_list_at()
Mike Becker <universe@uap-core.de>
parents:
435
diff
changeset
|
54 | d.next = NULL; |
cd3069757010
add function cx_linked_list_at()
Mike Becker <universe@uap-core.de>
parents:
435
diff
changeset
|
55 | |
449 | 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)) | |
438
cd3069757010
add function cx_linked_list_at()
Mike Becker <universe@uap-core.de>
parents:
435
diff
changeset
|
61 | |
449 | 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)) | |
438
cd3069757010
add function cx_linked_list_at()
Mike Becker <universe@uap-core.de>
parents:
435
diff
changeset
|
67 | |
449 | 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) | |
438
cd3069757010
add function cx_linked_list_at()
Mike Becker <universe@uap-core.de>
parents:
435
diff
changeset
|
70 | } |
cd3069757010
add function cx_linked_list_at()
Mike Becker <universe@uap-core.de>
parents:
435
diff
changeset
|
71 | |
444
cb944fa1852a
rename test_cx_linked_list_add
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
443
diff
changeset
|
72 | void test_linked_list_add(void) { |
442
310019ddfe4e
add test for cx_linked_list_add
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
438
diff
changeset
|
73 | struct node { |
310019ddfe4e
add test for cx_linked_list_add
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
438
diff
changeset
|
74 | void *prev; |
310019ddfe4e
add test for cx_linked_list_add
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
438
diff
changeset
|
75 | void *next; |
310019ddfe4e
add test for cx_linked_list_add
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
438
diff
changeset
|
76 | }; |
449 | 77 | |
442
310019ddfe4e
add test for cx_linked_list_add
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
438
diff
changeset
|
78 | struct node nodes[4]; |
449 | 79 | |
442
310019ddfe4e
add test for cx_linked_list_add
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
438
diff
changeset
|
80 | // test with begin, end / prev, next |
449 | 81 | memset(nodes, 0, 4 * sizeof(struct node)); |
442
310019ddfe4e
add test for cx_linked_list_add
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
438
diff
changeset
|
82 | void *begin = NULL; |
310019ddfe4e
add test for cx_linked_list_add
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
438
diff
changeset
|
83 | void *end = NULL; |
449 | 84 | |
442
310019ddfe4e
add test for cx_linked_list_add
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
438
diff
changeset
|
85 | ptrdiff_t loc_prev = offsetof(struct node, prev); |
310019ddfe4e
add test for cx_linked_list_add
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
438
diff
changeset
|
86 | ptrdiff_t loc_next = offsetof(struct node, next); |
449 | 87 | |
453
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
88 | cx_linked_list_add(&begin, &end, loc_prev, loc_next, &nodes[0]); |
449 | 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) | |
93 | ||
453
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
94 | cx_linked_list_add(&begin, &end, loc_prev, loc_next, &nodes[1]); |
449 | 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]) | |
99 | ||
442
310019ddfe4e
add test for cx_linked_list_add
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
438
diff
changeset
|
100 | // test with begin only / prev, next |
449 | 101 | memset(nodes, 0, 4 * sizeof(struct node)); |
442
310019ddfe4e
add test for cx_linked_list_add
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
438
diff
changeset
|
102 | begin = NULL; |
310019ddfe4e
add test for cx_linked_list_add
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
438
diff
changeset
|
103 | end = NULL; |
449 | 104 | |
453
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
105 | cx_linked_list_add(&begin, NULL, loc_prev, loc_next, &nodes[0]); |
449 | 106 | CU_ASSERT_PTR_EQUAL(begin, &nodes[0]) |
453
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
107 | cx_linked_list_add(&begin, NULL, loc_prev, loc_next, &nodes[1]); |
449 | 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]) | |
111 | ||
453
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
112 | cx_linked_list_add(&begin, NULL, loc_prev, loc_next, &nodes[2]); |
449 | 113 | CU_ASSERT_PTR_EQUAL(nodes[1].next, &nodes[2]) |
114 | CU_ASSERT_PTR_EQUAL(nodes[2].prev, &nodes[1]) | |
115 | ||
442
310019ddfe4e
add test for cx_linked_list_add
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
438
diff
changeset
|
116 | // test with begin, end / next |
449 | 117 | memset(nodes, 0, 4 * sizeof(struct node)); |
442
310019ddfe4e
add test for cx_linked_list_add
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
438
diff
changeset
|
118 | begin = NULL; |
310019ddfe4e
add test for cx_linked_list_add
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
438
diff
changeset
|
119 | end = NULL; |
449 | 120 | |
453
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
121 | cx_linked_list_add(&begin, &end, -1, loc_next, &nodes[0]); |
449 | 122 | CU_ASSERT_PTR_EQUAL(begin, &nodes[0]) |
123 | CU_ASSERT_PTR_EQUAL(end, &nodes[0]) | |
453
bb144d08cd44
add some documentation and changes some signatures
Mike Becker <universe@uap-core.de>
parents:
449
diff
changeset
|
124 | cx_linked_list_add(&begin, &end, -1, loc_next, &nodes[1]); |
449 | 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) | |
442
310019ddfe4e
add test for cx_linked_list_add
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
438
diff
changeset
|
128 | } |
310019ddfe4e
add test for cx_linked_list_add
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
438
diff
changeset
|
129 | |
456
227c2eabbef8
change cx_linked_list_last() and add a test for it
Mike Becker <universe@uap-core.de>
parents:
455
diff
changeset
|
130 | void test_linked_list_last(void) { |
227c2eabbef8
change cx_linked_list_last() and add a test for it
Mike Becker <universe@uap-core.de>
parents:
455
diff
changeset
|
131 | CU_ASSERT_PTR_NULL(cx_linked_list_last(NULL, -1)) |
227c2eabbef8
change cx_linked_list_last() and add a test for it
Mike Becker <universe@uap-core.de>
parents:
455
diff
changeset
|
132 | CU_ASSERT_PTR_NULL(cx_linked_list_last(NULL, 0)) |
455 | 133 | |
456
227c2eabbef8
change cx_linked_list_last() and add a test for it
Mike Becker <universe@uap-core.de>
parents:
455
diff
changeset
|
134 | struct node { |
227c2eabbef8
change cx_linked_list_last() and add a test for it
Mike Becker <universe@uap-core.de>
parents:
455
diff
changeset
|
135 | int data; |
227c2eabbef8
change cx_linked_list_last() and add a test for it
Mike Becker <universe@uap-core.de>
parents:
455
diff
changeset
|
136 | void *next; |
227c2eabbef8
change cx_linked_list_last() and add a test for it
Mike Becker <universe@uap-core.de>
parents:
455
diff
changeset
|
137 | }; |
227c2eabbef8
change cx_linked_list_last() and add a test for it
Mike Becker <universe@uap-core.de>
parents:
455
diff
changeset
|
138 | ptrdiff_t loc = offsetof(struct node, next); |
227c2eabbef8
change cx_linked_list_last() and add a test for it
Mike Becker <universe@uap-core.de>
parents:
455
diff
changeset
|
139 | |
227c2eabbef8
change cx_linked_list_last() and add a test for it
Mike Becker <universe@uap-core.de>
parents:
455
diff
changeset
|
140 | struct node third = {3, NULL}; |
227c2eabbef8
change cx_linked_list_last() and add a test for it
Mike Becker <universe@uap-core.de>
parents:
455
diff
changeset
|
141 | struct node second = {2, &third}; |
227c2eabbef8
change cx_linked_list_last() and add a test for it
Mike Becker <universe@uap-core.de>
parents:
455
diff
changeset
|
142 | struct node first = {1, &second}; |
227c2eabbef8
change cx_linked_list_last() and add a test for it
Mike Becker <universe@uap-core.de>
parents:
455
diff
changeset
|
143 | |
227c2eabbef8
change cx_linked_list_last() and add a test for it
Mike Becker <universe@uap-core.de>
parents:
455
diff
changeset
|
144 | CU_ASSERT_PTR_EQUAL(cx_linked_list_last(&first, loc), &third) |
227c2eabbef8
change cx_linked_list_last() and add a test for it
Mike Becker <universe@uap-core.de>
parents:
455
diff
changeset
|
145 | CU_ASSERT_PTR_EQUAL(cx_linked_list_last(&second, loc), &third) |
227c2eabbef8
change cx_linked_list_last() and add a test for it
Mike Becker <universe@uap-core.de>
parents:
455
diff
changeset
|
146 | CU_ASSERT_PTR_EQUAL(cx_linked_list_last(&third, loc), &third) |
227c2eabbef8
change cx_linked_list_last() and add a test for it
Mike Becker <universe@uap-core.de>
parents:
455
diff
changeset
|
147 | } |
227c2eabbef8
change cx_linked_list_last() and add a test for it
Mike Becker <universe@uap-core.de>
parents:
455
diff
changeset
|
148 | |
227c2eabbef8
change cx_linked_list_last() and add a test for it
Mike Becker <universe@uap-core.de>
parents:
455
diff
changeset
|
149 | |
227c2eabbef8
change cx_linked_list_last() and add a test for it
Mike Becker <universe@uap-core.de>
parents:
455
diff
changeset
|
150 | void test_hl_linked_list_create(void) { |
455 | 151 | cxTestingAllocatorReset(); |
152 | ||
153 | CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int)); | |
154 | ||
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) | |
160 | ||
161 | // assume this structure for a linked list | |
162 | struct ll_check { | |
163 | cx_list_s base; | |
164 | void *begin; | |
165 | void *end; | |
166 | }; | |
167 | ||
168 | struct ll_check *actual = (struct ll_check *) list; | |
169 | CU_ASSERT_PTR_NULL(actual->begin) | |
170 | CU_ASSERT_PTR_NULL(actual->end) | |
171 | ||
172 | cxLinkedListDestroy(list); | |
173 | ||
174 | CU_ASSERT_TRUE(cxTestingAllocatorVerify()) | |
175 | } | |
176 | ||
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
177 | void test_hl_linked_list_add(void) { |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
178 | cxTestingAllocatorReset(); |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
179 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
180 | int data; |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
181 | CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int)); |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
182 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
183 | data = 5; |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
184 | CU_ASSERT_EQUAL(cxListAdd(list, &data), 0) |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
185 | data = 47; |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
186 | CU_ASSERT_EQUAL(cxListAdd(list, &data), 0) |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
187 | data = 13; |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
188 | CU_ASSERT_EQUAL(cxListAdd(list, &data), 0) |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
189 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
190 | CU_ASSERT_EQUAL(list->size, 3) |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
191 | CU_ASSERT_TRUE(list->capacity >= list->size) |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
192 | |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
193 | CU_ASSERT_EQUAL(*(int*)cxListAt(list, 0), 5) |
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
194 | CU_ASSERT_EQUAL(*(int*)cxListAt(list, 1), 47) |
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
195 | CU_ASSERT_EQUAL(*(int*)cxListAt(list, 2), 13) |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
196 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
197 | cxLinkedListDestroy(list); |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
198 | CU_ASSERT_TRUE(cxTestingAllocatorVerify()) |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
199 | } |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
200 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
201 | void test_hl_linked_list_last(void) { |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
202 | cxTestingAllocatorReset(); |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
203 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
204 | int data; |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
205 | CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int)); |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
206 | |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
207 | CU_ASSERT_PTR_NULL(cxListLast(list)) |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
208 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
209 | data = 5; |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
210 | CU_ASSERT_EQUAL(cxListAdd(list, &data), 0) |
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
211 | CU_ASSERT_EQUAL(*(int*)cxListLast(list), 5) |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
212 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
213 | data = 47; |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
214 | CU_ASSERT_EQUAL(cxListAdd(list, &data), 0) |
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
215 | CU_ASSERT_EQUAL(*(int*)cxListLast(list), 47) |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
216 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
217 | cxLinkedListDestroy(list); |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
218 | CU_ASSERT_TRUE(cxTestingAllocatorVerify()) |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
219 | } |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
220 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
221 | void test_hl_linked_list_insert(void) { |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
222 | cxTestingAllocatorReset(); |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
223 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
224 | int data; |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
225 | CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int)); |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
226 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
227 | data = 5; |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
228 | CU_ASSERT_NOT_EQUAL(cxListInsert(list, 1, &data), 0) |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
229 | CU_ASSERT_EQUAL(list->size, 0) |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
230 | CU_ASSERT_EQUAL(cxListInsert(list, 0, &data), 0) |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
231 | CU_ASSERT_EQUAL(list->size, 1) |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
232 | data = 47; |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
233 | CU_ASSERT_EQUAL(cxListInsert(list, 0, &data), 0) |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
234 | CU_ASSERT_EQUAL(list->size, 2) |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
235 | data = 13; |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
236 | CU_ASSERT_EQUAL(cxListInsert(list, 1, &data), 0) |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
237 | CU_ASSERT_EQUAL(list->size, 3) |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
238 | data = 42; |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
239 | CU_ASSERT_EQUAL(cxListInsert(list, 3, &data), 0) |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
240 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
241 | CU_ASSERT_EQUAL(list->size, 4) |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
242 | CU_ASSERT_TRUE(list->capacity >= list->size) |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
243 | |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
244 | CU_ASSERT_EQUAL(*(int*)cxListAt(list, 0), 47) |
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
245 | CU_ASSERT_EQUAL(*(int*)cxListAt(list, 1), 13) |
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
246 | CU_ASSERT_EQUAL(*(int*)cxListAt(list, 2), 5) |
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
247 | CU_ASSERT_EQUAL(*(int*)cxListAt(list, 3), 42) |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
248 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
249 | cxLinkedListDestroy(list); |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
250 | CU_ASSERT_TRUE(cxTestingAllocatorVerify()) |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
251 | } |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
252 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
253 | void test_hl_linked_list_remove(void) { |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
254 | cxTestingAllocatorReset(); |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
255 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
256 | int data; |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
257 | CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int)); |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
258 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
259 | data = 5; |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
260 | cxListAdd(list, &data); |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
261 | data = 47; |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
262 | cxListAdd(list, &data); |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
263 | data = 42; |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
264 | cxListAdd(list, &data); |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
265 | data = 13; |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
266 | cxListAdd(list, &data); |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
267 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
268 | CU_ASSERT_EQUAL(list->size, 4) |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
269 | CU_ASSERT_TRUE(list->capacity >= list->size) |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
270 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
271 | CU_ASSERT_NOT_EQUAL(cxListRemove(list, 4), 0) |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
272 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
273 | CU_ASSERT_EQUAL(cxListRemove(list, 2), 0) |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
274 | CU_ASSERT_EQUAL(list->size, 3) |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
275 | CU_ASSERT_TRUE(list->capacity >= list->size) |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
276 | CU_ASSERT_EQUAL(*(int*)cxListAt(list, 0), 5) |
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
277 | CU_ASSERT_EQUAL(*(int*)cxListAt(list, 1), 47) |
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
278 | CU_ASSERT_EQUAL(*(int*)cxListAt(list, 2), 13) |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
279 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
280 | CU_ASSERT_EQUAL(cxListRemove(list, 0), 0) |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
281 | CU_ASSERT_EQUAL(list->size, 2) |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
282 | CU_ASSERT_TRUE(list->capacity >= list->size) |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
283 | CU_ASSERT_EQUAL(*(int*)cxListAt(list, 0), 47) |
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
284 | CU_ASSERT_EQUAL(*(int*)cxListAt(list, 1), 13) |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
285 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
286 | CU_ASSERT_EQUAL(cxListRemove(list, 1), 0) |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
287 | CU_ASSERT_EQUAL(list->size, 1) |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
288 | CU_ASSERT_TRUE(list->capacity >= list->size) |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
289 | CU_ASSERT_EQUAL(*(int*)cxListAt(list, 0), 47) |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
290 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
291 | CU_ASSERT_EQUAL(cxListRemove(list, 0), 0) |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
292 | CU_ASSERT_EQUAL(list->size, 0) |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
293 | CU_ASSERT_TRUE(list->capacity >= list->size) |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
294 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
295 | CU_ASSERT_NOT_EQUAL(cxListRemove(list, 0), 0) |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
296 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
297 | cxLinkedListDestroy(list); |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
298 | CU_ASSERT_TRUE(cxTestingAllocatorVerify()) |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
299 | } |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
300 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
301 | void test_hl_linked_list_find(void) { |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
302 | cxTestingAllocatorReset(); |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
303 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
304 | int data, criteria; |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
305 | CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int)); |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
306 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
307 | data = 5; |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
308 | cxListAdd(list, &data); |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
309 | data = 47; |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
310 | cxListAdd(list, &data); |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
311 | data = 13; |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
312 | cxListAdd(list, &data); |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
313 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
314 | CU_ASSERT_EQUAL(list->size, 3) |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
315 | CU_ASSERT_TRUE(list->capacity >= list->size) |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
316 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
317 | criteria = 5; |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
318 | CU_ASSERT_EQUAL(cxListFind(list, &criteria), 0) |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
319 | criteria = 47; |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
320 | CU_ASSERT_EQUAL(cxListFind(list, &criteria), 1) |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
321 | criteria = 13; |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
322 | CU_ASSERT_EQUAL(cxListFind(list, &criteria), 2) |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
323 | criteria = 9000; |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
324 | CU_ASSERT_EQUAL(cxListFind(list, &criteria), 3) |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
325 | criteria = -5; |
460
e075009b33b7
remove convenience macros
Mike Becker <universe@uap-core.de>
parents:
459
diff
changeset
|
326 | CU_ASSERT_EQUAL(cxListFind(list, &criteria), 3) |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
327 | |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
328 | cxLinkedListDestroy(list); |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
329 | CU_ASSERT_TRUE(cxTestingAllocatorVerify()) |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
330 | } |
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
331 | |
390 | 332 | int main() { |
411
2842f729caab
add first test suite to test_linked_list.c
Mike Becker <universe@uap-core.de>
parents:
398
diff
changeset
|
333 | CU_pSuite suite = NULL; |
449 | 334 | |
411
2842f729caab
add first test suite to test_linked_list.c
Mike Becker <universe@uap-core.de>
parents:
398
diff
changeset
|
335 | if (CUE_SUCCESS != CU_initialize_registry()) { |
2842f729caab
add first test suite to test_linked_list.c
Mike Becker <universe@uap-core.de>
parents:
398
diff
changeset
|
336 | return CU_get_error(); |
2842f729caab
add first test suite to test_linked_list.c
Mike Becker <universe@uap-core.de>
parents:
398
diff
changeset
|
337 | } |
2842f729caab
add first test suite to test_linked_list.c
Mike Becker <universe@uap-core.de>
parents:
398
diff
changeset
|
338 | |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
339 | suite = CU_add_suite("low level linked list", NULL, NULL); |
449 | 340 | |
455 | 341 | cu_add_test(suite, test_linked_list_at); |
342 | cu_add_test(suite, test_linked_list_add); | |
456
227c2eabbef8
change cx_linked_list_last() and add a test for it
Mike Becker <universe@uap-core.de>
parents:
455
diff
changeset
|
343 | cu_add_test(suite, test_linked_list_last); |
455 | 344 | |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
345 | suite = CU_add_suite("high level linked list", NULL, NULL); |
455 | 346 | |
456
227c2eabbef8
change cx_linked_list_last() and add a test for it
Mike Becker <universe@uap-core.de>
parents:
455
diff
changeset
|
347 | cu_add_test(suite, test_hl_linked_list_create); |
227c2eabbef8
change cx_linked_list_last() and add a test for it
Mike Becker <universe@uap-core.de>
parents:
455
diff
changeset
|
348 | cu_add_test(suite, test_hl_linked_list_add); |
227c2eabbef8
change cx_linked_list_last() and add a test for it
Mike Becker <universe@uap-core.de>
parents:
455
diff
changeset
|
349 | cu_add_test(suite, test_hl_linked_list_last); |
227c2eabbef8
change cx_linked_list_last() and add a test for it
Mike Becker <universe@uap-core.de>
parents:
455
diff
changeset
|
350 | cu_add_test(suite, test_hl_linked_list_insert); |
227c2eabbef8
change cx_linked_list_last() and add a test for it
Mike Becker <universe@uap-core.de>
parents:
455
diff
changeset
|
351 | cu_add_test(suite, test_hl_linked_list_remove); |
459
c0e2e9f83399
add tests for high level functions
Mike Becker <universe@uap-core.de>
parents:
456
diff
changeset
|
352 | cu_add_test(suite, test_hl_linked_list_find); |
413
0f4aa9fc75d9
perform array and list tests in the same test binary (use the same assertions, later)
Mike Becker <universe@uap-core.de>
parents:
412
diff
changeset
|
353 | |
411
2842f729caab
add first test suite to test_linked_list.c
Mike Becker <universe@uap-core.de>
parents:
398
diff
changeset
|
354 | CU_basic_set_mode(UCX_CU_BRM); |
2842f729caab
add first test suite to test_linked_list.c
Mike Becker <universe@uap-core.de>
parents:
398
diff
changeset
|
355 | |
2842f729caab
add first test suite to test_linked_list.c
Mike Becker <universe@uap-core.de>
parents:
398
diff
changeset
|
356 | int exitcode; |
2842f729caab
add first test suite to test_linked_list.c
Mike Becker <universe@uap-core.de>
parents:
398
diff
changeset
|
357 | if (CU_basic_run_tests()) { |
2842f729caab
add first test suite to test_linked_list.c
Mike Becker <universe@uap-core.de>
parents:
398
diff
changeset
|
358 | exitcode = CU_get_error(); |
2842f729caab
add first test suite to test_linked_list.c
Mike Becker <universe@uap-core.de>
parents:
398
diff
changeset
|
359 | } else { |
2842f729caab
add first test suite to test_linked_list.c
Mike Becker <universe@uap-core.de>
parents:
398
diff
changeset
|
360 | exitcode = CU_get_number_of_failures() == 0 ? 0 : 1; |
2842f729caab
add first test suite to test_linked_list.c
Mike Becker <universe@uap-core.de>
parents:
398
diff
changeset
|
361 | } |
2842f729caab
add first test suite to test_linked_list.c
Mike Becker <universe@uap-core.de>
parents:
398
diff
changeset
|
362 | CU_cleanup_registry(); |
2842f729caab
add first test suite to test_linked_list.c
Mike Becker <universe@uap-core.de>
parents:
398
diff
changeset
|
363 | return exitcode; |
390 | 364 | } |