Wed, 06 Oct 2021 14:10:19 +0200
add high level list sort and inlines method invocation functions
universe@390 | 1 | /* |
universe@390 | 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
universe@390 | 3 | * |
universe@390 | 4 | * Copyright 2021 Mike Becker, Olaf Wintermann All rights reserved. |
universe@390 | 5 | * |
universe@390 | 6 | * Redistribution and use in source and binary forms, with or without |
universe@390 | 7 | * modification, are permitted provided that the following conditions are met: |
universe@390 | 8 | * |
universe@390 | 9 | * 1. Redistributions of source code must retain the above copyright |
universe@390 | 10 | * notice, this list of conditions and the following disclaimer. |
universe@390 | 11 | * |
universe@390 | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
universe@390 | 13 | * notice, this list of conditions and the following disclaimer in the |
universe@390 | 14 | * documentation and/or other materials provided with the distribution. |
universe@390 | 15 | * |
universe@390 | 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
universe@390 | 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
universe@390 | 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
universe@390 | 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
universe@390 | 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
universe@390 | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
universe@390 | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
universe@390 | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
universe@390 | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
universe@390 | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
universe@390 | 26 | * POSSIBILITY OF SUCH DAMAGE. |
universe@390 | 27 | */ |
universe@390 | 28 | |
universe@398 | 29 | #include "cx/linked_list.h" |
universe@411 | 30 | #include "test_config.h" |
universe@422 | 31 | #include "util_allocator.h" |
universe@398 | 32 | |
universe@412 | 33 | int cmp_int(int const *l, int const *r) { |
universe@412 | 34 | int left = *l, right = *r; |
universe@412 | 35 | return left == right ? 0 : (left < right ? -1 : 1); |
universe@412 | 36 | } |
universe@412 | 37 | |
universe@438 | 38 | void test_linked_list_at(void) { |
universe@438 | 39 | struct node { |
universe@438 | 40 | void *next; |
universe@438 | 41 | void *prev; |
universe@438 | 42 | }; |
universe@438 | 43 | const ptrdiff_t loc_prev = offsetof(struct node, prev); |
universe@438 | 44 | const ptrdiff_t loc_next = offsetof(struct node, next); |
universe@438 | 45 | |
universe@438 | 46 | struct node a, b, c, d; |
universe@438 | 47 | a.prev = NULL; |
universe@438 | 48 | a.next = &b; |
universe@438 | 49 | b.prev = &a; |
universe@438 | 50 | b.next = &c; |
universe@438 | 51 | c.prev = &b; |
universe@438 | 52 | c.next = &d; |
universe@438 | 53 | d.prev = &c; |
universe@438 | 54 | d.next = NULL; |
universe@438 | 55 | |
universe@449 | 56 | CU_ASSERT_PTR_EQUAL(cx_linked_list_at(&a, 0, loc_next, 0), &a) |
universe@449 | 57 | CU_ASSERT_PTR_EQUAL(cx_linked_list_at(&a, 0, loc_next, 1), &b) |
universe@449 | 58 | CU_ASSERT_PTR_EQUAL(cx_linked_list_at(&a, 0, loc_next, 2), &c) |
universe@449 | 59 | CU_ASSERT_PTR_EQUAL(cx_linked_list_at(&a, 0, loc_next, 3), &d) |
universe@449 | 60 | CU_ASSERT_PTR_NULL(cx_linked_list_at(&a, 0, loc_next, 4)) |
universe@438 | 61 | |
universe@449 | 62 | CU_ASSERT_PTR_EQUAL(cx_linked_list_at(&b, 1, loc_prev, 0), &a) |
universe@449 | 63 | CU_ASSERT_PTR_EQUAL(cx_linked_list_at(&b, 1, loc_next, 1), &b) |
universe@449 | 64 | CU_ASSERT_PTR_EQUAL(cx_linked_list_at(&b, 1, loc_next, 2), &c) |
universe@449 | 65 | CU_ASSERT_PTR_EQUAL(cx_linked_list_at(&b, 1, loc_next, 3), &d) |
universe@449 | 66 | CU_ASSERT_PTR_NULL(cx_linked_list_at(&b, 1, loc_next, 4)) |
universe@438 | 67 | |
universe@449 | 68 | CU_ASSERT_PTR_EQUAL(cx_linked_list_at(&d, 3, loc_prev, 0), &a) |
universe@449 | 69 | CU_ASSERT_PTR_EQUAL(cx_linked_list_at(&d, 3, loc_prev, 1), &b) |
universe@438 | 70 | } |
universe@438 | 71 | |
olaf@444 | 72 | void test_linked_list_add(void) { |
olaf@442 | 73 | struct node { |
olaf@442 | 74 | void *prev; |
olaf@442 | 75 | void *next; |
olaf@442 | 76 | }; |
universe@449 | 77 | |
olaf@442 | 78 | struct node nodes[4]; |
universe@449 | 79 | |
olaf@442 | 80 | // test with begin, end / prev, next |
universe@449 | 81 | memset(nodes, 0, 4 * sizeof(struct node)); |
olaf@442 | 82 | void *begin = NULL; |
olaf@442 | 83 | void *end = NULL; |
universe@449 | 84 | |
olaf@442 | 85 | ptrdiff_t loc_prev = offsetof(struct node, prev); |
olaf@442 | 86 | ptrdiff_t loc_next = offsetof(struct node, next); |
universe@449 | 87 | |
universe@453 | 88 | cx_linked_list_add(&begin, &end, loc_prev, loc_next, &nodes[0]); |
universe@449 | 89 | CU_ASSERT_PTR_EQUAL(begin, &nodes[0]) |
universe@449 | 90 | CU_ASSERT_PTR_EQUAL(end, &nodes[0]) |
universe@449 | 91 | CU_ASSERT_PTR_EQUAL(nodes[0].prev, NULL) |
universe@449 | 92 | CU_ASSERT_PTR_EQUAL(nodes[0].next, NULL) |
universe@449 | 93 | |
universe@453 | 94 | cx_linked_list_add(&begin, &end, loc_prev, loc_next, &nodes[1]); |
universe@449 | 95 | CU_ASSERT_PTR_EQUAL(begin, &nodes[0]) |
universe@449 | 96 | CU_ASSERT_PTR_EQUAL(end, &nodes[1]) |
universe@449 | 97 | CU_ASSERT_PTR_EQUAL(nodes[0].next, &nodes[1]) |
universe@449 | 98 | CU_ASSERT_PTR_EQUAL(nodes[1].prev, &nodes[0]) |
universe@449 | 99 | |
olaf@442 | 100 | // test with begin only / prev, next |
universe@449 | 101 | memset(nodes, 0, 4 * sizeof(struct node)); |
olaf@442 | 102 | begin = NULL; |
olaf@442 | 103 | end = NULL; |
universe@449 | 104 | |
universe@453 | 105 | cx_linked_list_add(&begin, NULL, loc_prev, loc_next, &nodes[0]); |
universe@449 | 106 | CU_ASSERT_PTR_EQUAL(begin, &nodes[0]) |
universe@453 | 107 | cx_linked_list_add(&begin, NULL, loc_prev, loc_next, &nodes[1]); |
universe@449 | 108 | CU_ASSERT_PTR_EQUAL(begin, &nodes[0]) |
universe@449 | 109 | CU_ASSERT_PTR_EQUAL(nodes[0].next, &nodes[1]) |
universe@449 | 110 | CU_ASSERT_PTR_EQUAL(nodes[1].prev, &nodes[0]) |
universe@449 | 111 | |
universe@453 | 112 | cx_linked_list_add(&begin, NULL, loc_prev, loc_next, &nodes[2]); |
universe@449 | 113 | CU_ASSERT_PTR_EQUAL(nodes[1].next, &nodes[2]) |
universe@449 | 114 | CU_ASSERT_PTR_EQUAL(nodes[2].prev, &nodes[1]) |
universe@449 | 115 | |
olaf@442 | 116 | // test with begin, end / next |
universe@449 | 117 | memset(nodes, 0, 4 * sizeof(struct node)); |
olaf@442 | 118 | begin = NULL; |
olaf@442 | 119 | end = NULL; |
universe@449 | 120 | |
universe@453 | 121 | cx_linked_list_add(&begin, &end, -1, loc_next, &nodes[0]); |
universe@449 | 122 | CU_ASSERT_PTR_EQUAL(begin, &nodes[0]) |
universe@449 | 123 | CU_ASSERT_PTR_EQUAL(end, &nodes[0]) |
universe@453 | 124 | cx_linked_list_add(&begin, &end, -1, loc_next, &nodes[1]); |
universe@449 | 125 | CU_ASSERT_PTR_EQUAL(end, &nodes[1]) |
universe@449 | 126 | CU_ASSERT_PTR_EQUAL(nodes[0].next, &nodes[1]) |
universe@449 | 127 | CU_ASSERT_PTR_NULL(nodes[1].prev) |
olaf@442 | 128 | } |
olaf@442 | 129 | |
universe@456 | 130 | void test_linked_list_last(void) { |
universe@456 | 131 | CU_ASSERT_PTR_NULL(cx_linked_list_last(NULL, -1)) |
universe@456 | 132 | CU_ASSERT_PTR_NULL(cx_linked_list_last(NULL, 0)) |
universe@455 | 133 | |
universe@456 | 134 | struct node { |
universe@456 | 135 | int data; |
universe@456 | 136 | void *next; |
universe@456 | 137 | }; |
universe@456 | 138 | ptrdiff_t loc = offsetof(struct node, next); |
universe@456 | 139 | |
universe@456 | 140 | struct node third = {3, NULL}; |
universe@456 | 141 | struct node second = {2, &third}; |
universe@456 | 142 | struct node first = {1, &second}; |
universe@456 | 143 | |
universe@456 | 144 | CU_ASSERT_PTR_EQUAL(cx_linked_list_last(&first, loc), &third) |
universe@456 | 145 | CU_ASSERT_PTR_EQUAL(cx_linked_list_last(&second, loc), &third) |
universe@456 | 146 | CU_ASSERT_PTR_EQUAL(cx_linked_list_last(&third, loc), &third) |
universe@456 | 147 | } |
universe@456 | 148 | |
universe@468 | 149 | void test_linked_list_size(void) { |
universe@468 | 150 | struct node { |
universe@468 | 151 | void *next; |
universe@468 | 152 | }; |
universe@468 | 153 | ptrdiff_t loc = offsetof(struct node, next); |
universe@468 | 154 | |
universe@468 | 155 | struct node first = {NULL}; |
universe@468 | 156 | struct node second = {NULL}; |
universe@468 | 157 | struct node third = {NULL}; |
universe@468 | 158 | |
universe@468 | 159 | CU_ASSERT_PTR_EQUAL(cx_linked_list_size(NULL, loc), 0) |
universe@468 | 160 | CU_ASSERT_PTR_EQUAL(cx_linked_list_size(&first, loc), 1) |
universe@468 | 161 | first.next = &second; |
universe@468 | 162 | CU_ASSERT_PTR_EQUAL(cx_linked_list_size(&first, loc), 2) |
universe@468 | 163 | second.next = &third; |
universe@468 | 164 | CU_ASSERT_PTR_EQUAL(cx_linked_list_size(&first, loc), 3) |
universe@468 | 165 | CU_ASSERT_PTR_EQUAL(cx_linked_list_size(&second, loc), 2) |
universe@468 | 166 | } |
universe@468 | 167 | |
universe@468 | 168 | void test_linked_list_sort(void) { |
universe@468 | 169 | struct node { |
universe@468 | 170 | void *prev; |
universe@468 | 171 | void *next; |
universe@468 | 172 | int data; |
universe@468 | 173 | }; |
universe@468 | 174 | |
universe@468 | 175 | int expected[] = { |
universe@468 | 176 | 14, 30, 151, 163, 227, 300, 315, 317, 363, 398, 417, 424, 438, 446, 508, 555, 605, 713, 716, 759, 761, 880, |
universe@468 | 177 | 894, 1034, 1077, 1191, 1231, 1264, 1297, 1409, 1423, 1511, 1544, 1659, 1686, 1707, 1734, 1771, 1874, 1894, |
universe@468 | 178 | 1976, 2079, 2124, 2130, 2135, 2266, 2338, 2358, 2430, 2500, 2540, 2542, 2546, 2711, 2733, 2754, 2764, 2797, |
universe@468 | 179 | 2888, 2900, 3020, 3053, 3109, 3244, 3275, 3302, 3362, 3363, 3364, 3441, 3515, 3539, 3579, 3655, 3675, 3677, |
universe@468 | 180 | 3718, 3724, 3757, 3866, 3896, 3906, 3941, 3984, 3994, 4016, 4085, 4121, 4254, 4319, 4366, 4459, 4514, 4681, |
universe@468 | 181 | 4785, 4791, 4801, 4859, 4903, 4973 |
universe@468 | 182 | }; |
universe@468 | 183 | int scrambled[] = { |
universe@468 | 184 | 759, 716, 880, 761, 2358, 2542, 2500, 2540, 2546, 2711, 2430, 1707, 1874, 1771, 1894, 1734, 1976, 2079, |
universe@468 | 185 | 2124, 2130, 2135, 2266, 2338, 2733, 2754, 2764, 2797, 3362, 3363, 3364, 3441, 3515, 3539, 3579, 3655, 2888, |
universe@468 | 186 | 2900, 3020, 3053, 3109, 3244, 3275, 3302, 438, 446, 508, 555, 605, 713, 14, 30, 151, 163, 227, 300, |
universe@468 | 187 | 894, 1034, 1077, 1191, 1231, 1264, 1297, 1409, 1423, 1511, 1544, 1659, 1686, 315, 317, 363, 398, 417, 424, |
universe@468 | 188 | 3675, 3677, 3718, 3724, 3757, 3866, 3896, 3906, 3941, 3984, 3994, 4785, 4791, 4801, 4859, 4903, 4973, |
universe@468 | 189 | 4016, 4085, 4121, 4254, 4319, 4366, 4459, 4514, 4681 |
universe@468 | 190 | }; |
universe@468 | 191 | |
universe@468 | 192 | struct node *nodes = calloc(100, sizeof(struct node)); |
universe@468 | 193 | for (int i = 0; i < 100; i++) { |
universe@468 | 194 | nodes[i].prev = i == 0 ? NULL : &nodes[i - 1]; |
universe@468 | 195 | nodes[i].next = i == 99 ? NULL : &nodes[i + 1]; |
universe@468 | 196 | nodes[i].data = scrambled[i]; |
universe@468 | 197 | } |
universe@468 | 198 | |
universe@468 | 199 | struct node *begin = &nodes[0]; |
universe@468 | 200 | struct node *end = &nodes[99]; |
universe@468 | 201 | |
universe@468 | 202 | cx_linked_list_sort((void **) &begin, (void **) &end, |
universe@468 | 203 | offsetof(struct node, prev), |
universe@468 | 204 | offsetof(struct node, next), |
universe@468 | 205 | offsetof(struct node, data), |
universe@468 | 206 | 0, (CxListComparator) cmp_int); |
universe@468 | 207 | |
universe@468 | 208 | CU_ASSERT_PTR_NULL(begin->prev) |
universe@468 | 209 | CU_ASSERT_EQUAL(begin->data, expected[0]) |
universe@468 | 210 | struct node *check = begin; |
universe@468 | 211 | struct node *check_last = NULL; |
universe@468 | 212 | for (int i = 0 ; i < 100 ; i++) { |
universe@468 | 213 | CU_ASSERT_EQUAL(check->data, expected[i]) |
universe@468 | 214 | CU_ASSERT_PTR_EQUAL(check->prev, check_last) |
universe@468 | 215 | if (i < 99) { |
universe@468 | 216 | CU_ASSERT_PTR_NOT_NULL(check->next) |
universe@468 | 217 | } |
universe@468 | 218 | check_last = check; |
universe@468 | 219 | check = check->next; |
universe@468 | 220 | } |
universe@468 | 221 | CU_ASSERT_PTR_NULL(check) |
universe@468 | 222 | CU_ASSERT_EQUAL(end->data, expected[99]) |
universe@468 | 223 | } |
universe@468 | 224 | |
universe@456 | 225 | |
universe@456 | 226 | void test_hl_linked_list_create(void) { |
universe@455 | 227 | cxTestingAllocatorReset(); |
universe@455 | 228 | |
universe@455 | 229 | CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int)); |
universe@455 | 230 | |
universe@455 | 231 | CU_ASSERT_EQUAL(list->size, 0) |
universe@455 | 232 | CU_ASSERT_EQUAL(list->capacity, (size_t) -1) |
universe@455 | 233 | CU_ASSERT_PTR_EQUAL(list->allocator, cxTestingAllocator) |
universe@455 | 234 | CU_ASSERT_EQUAL(list->itemsize, sizeof(int)) |
universe@455 | 235 | CU_ASSERT_PTR_EQUAL(list->cmpfunc, cmp_int) |
universe@455 | 236 | |
universe@455 | 237 | cxLinkedListDestroy(list); |
universe@455 | 238 | CU_ASSERT_TRUE(cxTestingAllocatorVerify()) |
universe@455 | 239 | } |
universe@455 | 240 | |
universe@459 | 241 | void test_hl_linked_list_add(void) { |
universe@459 | 242 | cxTestingAllocatorReset(); |
universe@459 | 243 | |
universe@459 | 244 | int data; |
universe@459 | 245 | CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int)); |
universe@459 | 246 | |
universe@459 | 247 | data = 5; |
universe@460 | 248 | CU_ASSERT_EQUAL(cxListAdd(list, &data), 0) |
universe@459 | 249 | data = 47; |
universe@460 | 250 | CU_ASSERT_EQUAL(cxListAdd(list, &data), 0) |
universe@459 | 251 | data = 13; |
universe@460 | 252 | CU_ASSERT_EQUAL(cxListAdd(list, &data), 0) |
universe@459 | 253 | |
universe@459 | 254 | CU_ASSERT_EQUAL(list->size, 3) |
universe@459 | 255 | CU_ASSERT_TRUE(list->capacity >= list->size) |
universe@459 | 256 | |
universe@466 | 257 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 0), 5) |
universe@466 | 258 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 1), 47) |
universe@466 | 259 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 2), 13) |
universe@459 | 260 | |
universe@459 | 261 | cxLinkedListDestroy(list); |
universe@459 | 262 | CU_ASSERT_TRUE(cxTestingAllocatorVerify()) |
universe@459 | 263 | } |
universe@459 | 264 | |
universe@459 | 265 | void test_hl_linked_list_last(void) { |
universe@459 | 266 | cxTestingAllocatorReset(); |
universe@459 | 267 | |
universe@459 | 268 | int data; |
universe@459 | 269 | CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int)); |
universe@459 | 270 | |
universe@460 | 271 | CU_ASSERT_PTR_NULL(cxListLast(list)) |
universe@459 | 272 | |
universe@459 | 273 | data = 5; |
universe@460 | 274 | CU_ASSERT_EQUAL(cxListAdd(list, &data), 0) |
universe@466 | 275 | CU_ASSERT_EQUAL(*(int *) cxListLast(list), 5) |
universe@459 | 276 | |
universe@459 | 277 | data = 47; |
universe@460 | 278 | CU_ASSERT_EQUAL(cxListAdd(list, &data), 0) |
universe@466 | 279 | CU_ASSERT_EQUAL(*(int *) cxListLast(list), 47) |
universe@459 | 280 | |
universe@459 | 281 | cxLinkedListDestroy(list); |
universe@459 | 282 | CU_ASSERT_TRUE(cxTestingAllocatorVerify()) |
universe@459 | 283 | } |
universe@459 | 284 | |
universe@459 | 285 | void test_hl_linked_list_insert(void) { |
universe@459 | 286 | cxTestingAllocatorReset(); |
universe@459 | 287 | |
universe@459 | 288 | int data; |
universe@459 | 289 | CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int)); |
universe@459 | 290 | |
universe@459 | 291 | data = 5; |
universe@460 | 292 | CU_ASSERT_NOT_EQUAL(cxListInsert(list, 1, &data), 0) |
universe@459 | 293 | CU_ASSERT_EQUAL(list->size, 0) |
universe@460 | 294 | CU_ASSERT_EQUAL(cxListInsert(list, 0, &data), 0) |
universe@459 | 295 | CU_ASSERT_EQUAL(list->size, 1) |
universe@459 | 296 | data = 47; |
universe@460 | 297 | CU_ASSERT_EQUAL(cxListInsert(list, 0, &data), 0) |
universe@459 | 298 | CU_ASSERT_EQUAL(list->size, 2) |
universe@459 | 299 | data = 13; |
universe@460 | 300 | CU_ASSERT_EQUAL(cxListInsert(list, 1, &data), 0) |
universe@459 | 301 | CU_ASSERT_EQUAL(list->size, 3) |
universe@459 | 302 | data = 42; |
universe@460 | 303 | CU_ASSERT_EQUAL(cxListInsert(list, 3, &data), 0) |
universe@459 | 304 | |
universe@459 | 305 | CU_ASSERT_EQUAL(list->size, 4) |
universe@459 | 306 | CU_ASSERT_TRUE(list->capacity >= list->size) |
universe@459 | 307 | |
universe@466 | 308 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 0), 47) |
universe@466 | 309 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 1), 13) |
universe@466 | 310 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 2), 5) |
universe@466 | 311 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 3), 42) |
universe@459 | 312 | |
universe@459 | 313 | cxLinkedListDestroy(list); |
universe@459 | 314 | CU_ASSERT_TRUE(cxTestingAllocatorVerify()) |
universe@459 | 315 | } |
universe@459 | 316 | |
universe@459 | 317 | void test_hl_linked_list_remove(void) { |
universe@459 | 318 | cxTestingAllocatorReset(); |
universe@459 | 319 | |
universe@459 | 320 | int data; |
universe@459 | 321 | CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int)); |
universe@459 | 322 | |
universe@459 | 323 | data = 5; |
universe@460 | 324 | cxListAdd(list, &data); |
universe@459 | 325 | data = 47; |
universe@460 | 326 | cxListAdd(list, &data); |
universe@459 | 327 | data = 42; |
universe@460 | 328 | cxListAdd(list, &data); |
universe@459 | 329 | data = 13; |
universe@460 | 330 | cxListAdd(list, &data); |
universe@459 | 331 | |
universe@459 | 332 | CU_ASSERT_EQUAL(list->size, 4) |
universe@459 | 333 | CU_ASSERT_TRUE(list->capacity >= list->size) |
universe@459 | 334 | |
universe@459 | 335 | CU_ASSERT_NOT_EQUAL(cxListRemove(list, 4), 0) |
universe@459 | 336 | |
universe@459 | 337 | CU_ASSERT_EQUAL(cxListRemove(list, 2), 0) |
universe@459 | 338 | CU_ASSERT_EQUAL(list->size, 3) |
universe@459 | 339 | CU_ASSERT_TRUE(list->capacity >= list->size) |
universe@466 | 340 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 0), 5) |
universe@466 | 341 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 1), 47) |
universe@466 | 342 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 2), 13) |
universe@459 | 343 | |
universe@459 | 344 | CU_ASSERT_EQUAL(cxListRemove(list, 0), 0) |
universe@459 | 345 | CU_ASSERT_EQUAL(list->size, 2) |
universe@459 | 346 | CU_ASSERT_TRUE(list->capacity >= list->size) |
universe@466 | 347 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 0), 47) |
universe@466 | 348 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 1), 13) |
universe@459 | 349 | |
universe@459 | 350 | CU_ASSERT_EQUAL(cxListRemove(list, 1), 0) |
universe@459 | 351 | CU_ASSERT_EQUAL(list->size, 1) |
universe@459 | 352 | CU_ASSERT_TRUE(list->capacity >= list->size) |
universe@466 | 353 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 0), 47) |
universe@459 | 354 | |
universe@459 | 355 | CU_ASSERT_EQUAL(cxListRemove(list, 0), 0) |
universe@459 | 356 | CU_ASSERT_EQUAL(list->size, 0) |
universe@459 | 357 | CU_ASSERT_TRUE(list->capacity >= list->size) |
universe@459 | 358 | |
universe@459 | 359 | CU_ASSERT_NOT_EQUAL(cxListRemove(list, 0), 0) |
universe@459 | 360 | |
universe@459 | 361 | cxLinkedListDestroy(list); |
universe@459 | 362 | CU_ASSERT_TRUE(cxTestingAllocatorVerify()) |
universe@459 | 363 | } |
universe@459 | 364 | |
universe@459 | 365 | void test_hl_linked_list_find(void) { |
universe@459 | 366 | cxTestingAllocatorReset(); |
universe@459 | 367 | |
universe@459 | 368 | int data, criteria; |
universe@459 | 369 | CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int)); |
universe@459 | 370 | |
universe@459 | 371 | data = 5; |
universe@460 | 372 | cxListAdd(list, &data); |
universe@459 | 373 | data = 47; |
universe@460 | 374 | cxListAdd(list, &data); |
universe@459 | 375 | data = 13; |
universe@460 | 376 | cxListAdd(list, &data); |
universe@459 | 377 | |
universe@459 | 378 | CU_ASSERT_EQUAL(list->size, 3) |
universe@459 | 379 | CU_ASSERT_TRUE(list->capacity >= list->size) |
universe@459 | 380 | |
universe@459 | 381 | criteria = 5; |
universe@460 | 382 | CU_ASSERT_EQUAL(cxListFind(list, &criteria), 0) |
universe@459 | 383 | criteria = 47; |
universe@460 | 384 | CU_ASSERT_EQUAL(cxListFind(list, &criteria), 1) |
universe@459 | 385 | criteria = 13; |
universe@460 | 386 | CU_ASSERT_EQUAL(cxListFind(list, &criteria), 2) |
universe@459 | 387 | criteria = 9000; |
universe@460 | 388 | CU_ASSERT_EQUAL(cxListFind(list, &criteria), 3) |
universe@459 | 389 | criteria = -5; |
universe@460 | 390 | CU_ASSERT_EQUAL(cxListFind(list, &criteria), 3) |
universe@459 | 391 | |
universe@459 | 392 | cxLinkedListDestroy(list); |
universe@459 | 393 | CU_ASSERT_TRUE(cxTestingAllocatorVerify()) |
universe@459 | 394 | } |
universe@459 | 395 | |
universe@469 | 396 | void test_hl_linked_list_sort(void) { |
universe@469 | 397 | int expected[] = { |
universe@469 | 398 | 14, 30, 151, 163, 227, 300, 315, 317, 363, 398, 417, 424, 438, 446, 508, 555, 605, 713, 716, 759, 761, 880, |
universe@469 | 399 | 894, 1034, 1077, 1191, 1231, 1264, 1297, 1409, 1423, 1511, 1544, 1659, 1686, 1707, 1734, 1771, 1874, 1894, |
universe@469 | 400 | 1976, 2079, 2124, 2130, 2135, 2266, 2338, 2358, 2430, 2500, 2540, 2542, 2546, 2711, 2733, 2754, 2764, 2797, |
universe@469 | 401 | 2888, 2900, 3020, 3053, 3109, 3244, 3275, 3302, 3362, 3363, 3364, 3441, 3515, 3539, 3579, 3655, 3675, 3677, |
universe@469 | 402 | 3718, 3724, 3757, 3866, 3896, 3906, 3941, 3984, 3994, 4016, 4085, 4121, 4254, 4319, 4366, 4459, 4514, 4681, |
universe@469 | 403 | 4785, 4791, 4801, 4859, 4903, 4973 |
universe@469 | 404 | }; |
universe@469 | 405 | int scrambled[] = { |
universe@469 | 406 | 759, 716, 880, 761, 2358, 2542, 2500, 2540, 2546, 2711, 2430, 1707, 1874, 1771, 1894, 1734, 1976, 2079, |
universe@469 | 407 | 2124, 2130, 2135, 2266, 2338, 2733, 2754, 2764, 2797, 3362, 3363, 3364, 3441, 3515, 3539, 3579, 3655, 2888, |
universe@469 | 408 | 2900, 3020, 3053, 3109, 3244, 3275, 3302, 438, 446, 508, 555, 605, 713, 14, 30, 151, 163, 227, 300, |
universe@469 | 409 | 894, 1034, 1077, 1191, 1231, 1264, 1297, 1409, 1423, 1511, 1544, 1659, 1686, 315, 317, 363, 398, 417, 424, |
universe@469 | 410 | 3675, 3677, 3718, 3724, 3757, 3866, 3896, 3906, 3941, 3984, 3994, 4785, 4791, 4801, 4859, 4903, 4973, |
universe@469 | 411 | 4016, 4085, 4121, 4254, 4319, 4366, 4459, 4514, 4681 |
universe@469 | 412 | }; |
universe@469 | 413 | |
universe@469 | 414 | cxTestingAllocatorReset(); |
universe@469 | 415 | |
universe@469 | 416 | CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int)); |
universe@469 | 417 | |
universe@469 | 418 | for (int i = 0 ; i < 100 ; i++) { |
universe@469 | 419 | cxListAdd(list, &scrambled[i]); |
universe@469 | 420 | } |
universe@469 | 421 | |
universe@469 | 422 | cxListSort(list); |
universe@469 | 423 | |
universe@469 | 424 | for (int i = 0 ; i < 100 ; i++) { |
universe@469 | 425 | CU_ASSERT_EQUAL(*(int*)cxListAt(list, i), expected[i]) |
universe@469 | 426 | } |
universe@469 | 427 | |
universe@469 | 428 | cxLinkedListDestroy(list); |
universe@469 | 429 | CU_ASSERT_TRUE(cxTestingAllocatorVerify()) |
universe@469 | 430 | } |
universe@469 | 431 | |
universe@466 | 432 | void test_hl_ptr_linked_list_create(void) { |
universe@466 | 433 | cxTestingAllocatorReset(); |
universe@466 | 434 | |
universe@466 | 435 | CxList list = cxPointerLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int); |
universe@466 | 436 | |
universe@466 | 437 | CU_ASSERT_EQUAL(list->size, 0) |
universe@466 | 438 | CU_ASSERT_EQUAL(list->capacity, (size_t) -1) |
universe@466 | 439 | CU_ASSERT_PTR_EQUAL(list->allocator, cxTestingAllocator) |
universe@466 | 440 | CU_ASSERT_EQUAL(list->itemsize, sizeof(void *)) |
universe@466 | 441 | CU_ASSERT_PTR_EQUAL(list->cmpfunc, cmp_int) |
universe@466 | 442 | |
universe@466 | 443 | cxLinkedListDestroy(list); |
universe@466 | 444 | CU_ASSERT_TRUE(cxTestingAllocatorVerify()) |
universe@466 | 445 | } |
universe@466 | 446 | |
universe@466 | 447 | void test_hl_ptr_linked_list_add(void) { |
universe@466 | 448 | cxTestingAllocatorReset(); |
universe@466 | 449 | |
universe@466 | 450 | CxList list = cxPointerLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int); |
universe@466 | 451 | |
universe@466 | 452 | int a = 5, b = 47, c = 13; |
universe@466 | 453 | |
universe@466 | 454 | CU_ASSERT_EQUAL(cxListAdd(list, &a), 0) |
universe@466 | 455 | CU_ASSERT_EQUAL(cxListAdd(list, &b), 0) |
universe@466 | 456 | CU_ASSERT_EQUAL(cxListAdd(list, &c), 0) |
universe@466 | 457 | |
universe@466 | 458 | CU_ASSERT_EQUAL(list->size, 3) |
universe@466 | 459 | CU_ASSERT_TRUE(list->capacity >= list->size) |
universe@466 | 460 | |
universe@466 | 461 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 0), 5) |
universe@466 | 462 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 1), 47) |
universe@466 | 463 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 2), 13) |
universe@466 | 464 | |
universe@466 | 465 | a = 9; |
universe@466 | 466 | b = 10; |
universe@466 | 467 | c = 11; |
universe@466 | 468 | |
universe@466 | 469 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 0), 9) |
universe@466 | 470 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 1), 10) |
universe@466 | 471 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 2), 11) |
universe@466 | 472 | |
universe@466 | 473 | cxLinkedListDestroy(list); |
universe@466 | 474 | CU_ASSERT_TRUE(cxTestingAllocatorVerify()) |
universe@466 | 475 | } |
universe@466 | 476 | |
universe@466 | 477 | void test_hl_ptr_linked_list_last(void) { |
universe@466 | 478 | cxTestingAllocatorReset(); |
universe@466 | 479 | |
universe@466 | 480 | CxList list = cxPointerLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int); |
universe@466 | 481 | CU_ASSERT_PTR_NULL(cxListLast(list)) |
universe@466 | 482 | |
universe@466 | 483 | int a = 5, b = 47; |
universe@466 | 484 | |
universe@466 | 485 | CU_ASSERT_EQUAL(cxListAdd(list, &a), 0) |
universe@466 | 486 | CU_ASSERT_EQUAL(*(int *) cxListLast(list), 5) |
universe@466 | 487 | CU_ASSERT_EQUAL(cxListAdd(list, &b), 0) |
universe@466 | 488 | CU_ASSERT_EQUAL(*(int *) cxListLast(list), 47) |
universe@466 | 489 | |
universe@466 | 490 | cxLinkedListDestroy(list); |
universe@466 | 491 | CU_ASSERT_TRUE(cxTestingAllocatorVerify()) |
universe@466 | 492 | } |
universe@466 | 493 | |
universe@466 | 494 | void test_hl_ptr_linked_list_insert(void) { |
universe@466 | 495 | cxTestingAllocatorReset(); |
universe@466 | 496 | |
universe@466 | 497 | CxList list = cxPointerLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int); |
universe@466 | 498 | |
universe@466 | 499 | int a = 5, b = 47, c = 13, d = 42; |
universe@466 | 500 | |
universe@466 | 501 | CU_ASSERT_NOT_EQUAL(cxListInsert(list, 1, &a), 0) |
universe@466 | 502 | CU_ASSERT_EQUAL(list->size, 0) |
universe@466 | 503 | CU_ASSERT_EQUAL(cxListInsert(list, 0, &a), 0) |
universe@466 | 504 | CU_ASSERT_EQUAL(list->size, 1) |
universe@466 | 505 | CU_ASSERT_EQUAL(cxListInsert(list, 0, &b), 0) |
universe@466 | 506 | CU_ASSERT_EQUAL(list->size, 2) |
universe@466 | 507 | CU_ASSERT_EQUAL(cxListInsert(list, 1, &c), 0) |
universe@466 | 508 | CU_ASSERT_EQUAL(list->size, 3) |
universe@466 | 509 | CU_ASSERT_EQUAL(cxListInsert(list, 3, &d), 0) |
universe@466 | 510 | |
universe@466 | 511 | CU_ASSERT_EQUAL(list->size, 4) |
universe@466 | 512 | CU_ASSERT_TRUE(list->capacity >= list->size) |
universe@466 | 513 | |
universe@466 | 514 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 0), 47) |
universe@466 | 515 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 1), 13) |
universe@466 | 516 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 2), 5) |
universe@466 | 517 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 3), 42) |
universe@466 | 518 | |
universe@466 | 519 | cxLinkedListDestroy(list); |
universe@466 | 520 | CU_ASSERT_TRUE(cxTestingAllocatorVerify()) |
universe@466 | 521 | } |
universe@466 | 522 | |
universe@466 | 523 | void test_hl_ptr_linked_list_remove(void) { |
universe@466 | 524 | cxTestingAllocatorReset(); |
universe@466 | 525 | |
universe@466 | 526 | int a = 5, b = 47, c = 42, d = 13; |
universe@466 | 527 | CxList list = cxPointerLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int); |
universe@466 | 528 | |
universe@466 | 529 | cxListAdd(list, &a); |
universe@466 | 530 | cxListAdd(list, &b); |
universe@466 | 531 | cxListAdd(list, &c); |
universe@466 | 532 | cxListAdd(list, &d); |
universe@466 | 533 | |
universe@466 | 534 | CU_ASSERT_EQUAL(list->size, 4) |
universe@466 | 535 | CU_ASSERT_TRUE(list->capacity >= list->size) |
universe@466 | 536 | |
universe@466 | 537 | CU_ASSERT_NOT_EQUAL(cxListRemove(list, 4), 0) |
universe@466 | 538 | |
universe@466 | 539 | CU_ASSERT_EQUAL(cxListRemove(list, 2), 0) |
universe@466 | 540 | CU_ASSERT_EQUAL(list->size, 3) |
universe@466 | 541 | CU_ASSERT_TRUE(list->capacity >= list->size) |
universe@466 | 542 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 0), 5) |
universe@466 | 543 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 1), 47) |
universe@466 | 544 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 2), 13) |
universe@466 | 545 | |
universe@466 | 546 | CU_ASSERT_EQUAL(cxListRemove(list, 0), 0) |
universe@466 | 547 | CU_ASSERT_EQUAL(list->size, 2) |
universe@466 | 548 | CU_ASSERT_TRUE(list->capacity >= list->size) |
universe@466 | 549 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 0), 47) |
universe@466 | 550 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 1), 13) |
universe@466 | 551 | |
universe@466 | 552 | CU_ASSERT_EQUAL(cxListRemove(list, 1), 0) |
universe@466 | 553 | CU_ASSERT_EQUAL(list->size, 1) |
universe@466 | 554 | CU_ASSERT_TRUE(list->capacity >= list->size) |
universe@466 | 555 | CU_ASSERT_EQUAL(*(int *) cxListAt(list, 0), 47) |
universe@466 | 556 | |
universe@466 | 557 | CU_ASSERT_EQUAL(cxListRemove(list, 0), 0) |
universe@466 | 558 | CU_ASSERT_EQUAL(list->size, 0) |
universe@466 | 559 | CU_ASSERT_TRUE(list->capacity >= list->size) |
universe@466 | 560 | |
universe@466 | 561 | CU_ASSERT_NOT_EQUAL(cxListRemove(list, 0), 0) |
universe@466 | 562 | |
universe@466 | 563 | cxLinkedListDestroy(list); |
universe@466 | 564 | CU_ASSERT_TRUE(cxTestingAllocatorVerify()) |
universe@466 | 565 | } |
universe@466 | 566 | |
universe@466 | 567 | void test_hl_ptr_linked_list_find(void) { |
universe@466 | 568 | cxTestingAllocatorReset(); |
universe@466 | 569 | |
universe@466 | 570 | int a = 5, b = 47, c = 13, criteria; |
universe@466 | 571 | CxList list = cxPointerLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int); |
universe@466 | 572 | |
universe@466 | 573 | cxListAdd(list, &a); |
universe@466 | 574 | cxListAdd(list, &b); |
universe@466 | 575 | cxListAdd(list, &c); |
universe@466 | 576 | |
universe@466 | 577 | CU_ASSERT_EQUAL(list->size, 3) |
universe@466 | 578 | CU_ASSERT_TRUE(list->capacity >= list->size) |
universe@466 | 579 | |
universe@466 | 580 | criteria = 5; |
universe@466 | 581 | CU_ASSERT_EQUAL(cxListFind(list, &criteria), 0) |
universe@466 | 582 | criteria = 47; |
universe@466 | 583 | CU_ASSERT_EQUAL(cxListFind(list, &criteria), 1) |
universe@466 | 584 | criteria = 13; |
universe@466 | 585 | CU_ASSERT_EQUAL(cxListFind(list, &criteria), 2) |
universe@466 | 586 | criteria = 9000; |
universe@466 | 587 | CU_ASSERT_EQUAL(cxListFind(list, &criteria), 3) |
universe@466 | 588 | criteria = -5; |
universe@466 | 589 | CU_ASSERT_EQUAL(cxListFind(list, &criteria), 3) |
universe@466 | 590 | b = -5; |
universe@466 | 591 | CU_ASSERT_EQUAL(cxListFind(list, &criteria), 1) |
universe@466 | 592 | |
universe@466 | 593 | cxLinkedListDestroy(list); |
universe@466 | 594 | CU_ASSERT_TRUE(cxTestingAllocatorVerify()) |
universe@466 | 595 | } |
universe@466 | 596 | |
universe@469 | 597 | void test_hl_ptr_linked_list_sort(void) { |
universe@469 | 598 | int expected[] = { |
universe@469 | 599 | 14, 30, 151, 163, 227, 300, 315, 317, 363, 398, 417, 424, 438, 446, 508, 555, 605, 713, 716, 759, 761, 880, |
universe@469 | 600 | 894, 1034, 1077, 1191, 1231, 1264, 1297, 1409, 1423, 1511, 1544, 1659, 1686, 1707, 1734, 1771, 1874, 1894, |
universe@469 | 601 | 1976, 2079, 2124, 2130, 2135, 2266, 2338, 2358, 2430, 2500, 2540, 2542, 2546, 2711, 2733, 2754, 2764, 2797, |
universe@469 | 602 | 2888, 2900, 3020, 3053, 3109, 3244, 3275, 3302, 3362, 3363, 3364, 3441, 3515, 3539, 3579, 3655, 3675, 3677, |
universe@469 | 603 | 3718, 3724, 3757, 3866, 3896, 3906, 3941, 3984, 3994, 4016, 4085, 4121, 4254, 4319, 4366, 4459, 4514, 4681, |
universe@469 | 604 | 4785, 4791, 4801, 4859, 4903, 4973 |
universe@469 | 605 | }; |
universe@469 | 606 | int scrambled[] = { |
universe@469 | 607 | 759, 716, 880, 761, 2358, 2542, 2500, 2540, 2546, 2711, 2430, 1707, 1874, 1771, 1894, 1734, 1976, 2079, |
universe@469 | 608 | 2124, 2130, 2135, 2266, 2338, 2733, 2754, 2764, 2797, 3362, 3363, 3364, 3441, 3515, 3539, 3579, 3655, 2888, |
universe@469 | 609 | 2900, 3020, 3053, 3109, 3244, 3275, 3302, 438, 446, 508, 555, 605, 713, 14, 30, 151, 163, 227, 300, |
universe@469 | 610 | 894, 1034, 1077, 1191, 1231, 1264, 1297, 1409, 1423, 1511, 1544, 1659, 1686, 315, 317, 363, 398, 417, 424, |
universe@469 | 611 | 3675, 3677, 3718, 3724, 3757, 3866, 3896, 3906, 3941, 3984, 3994, 4785, 4791, 4801, 4859, 4903, 4973, |
universe@469 | 612 | 4016, 4085, 4121, 4254, 4319, 4366, 4459, 4514, 4681 |
universe@469 | 613 | }; |
universe@469 | 614 | |
universe@469 | 615 | cxTestingAllocatorReset(); |
universe@469 | 616 | |
universe@469 | 617 | CxList list = cxPointerLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int); |
universe@469 | 618 | |
universe@469 | 619 | for (int i = 0 ; i < 100 ; i++) { |
universe@469 | 620 | cxListAdd(list, &scrambled[i]); |
universe@469 | 621 | } |
universe@469 | 622 | |
universe@469 | 623 | cxListSort(list); |
universe@469 | 624 | |
universe@469 | 625 | for (int i = 0 ; i < 100 ; i++) { |
universe@469 | 626 | CU_ASSERT_EQUAL(*(int*)cxListAt(list, i), expected[i]) |
universe@469 | 627 | } |
universe@469 | 628 | |
universe@469 | 629 | cxLinkedListDestroy(list); |
universe@469 | 630 | CU_ASSERT_TRUE(cxTestingAllocatorVerify()) |
universe@469 | 631 | } |
universe@469 | 632 | |
universe@390 | 633 | int main() { |
universe@411 | 634 | CU_pSuite suite = NULL; |
universe@449 | 635 | |
universe@411 | 636 | if (CUE_SUCCESS != CU_initialize_registry()) { |
universe@411 | 637 | return CU_get_error(); |
universe@411 | 638 | } |
universe@411 | 639 | |
universe@459 | 640 | suite = CU_add_suite("low level linked list", NULL, NULL); |
universe@449 | 641 | |
universe@455 | 642 | cu_add_test(suite, test_linked_list_at); |
universe@455 | 643 | cu_add_test(suite, test_linked_list_add); |
universe@456 | 644 | cu_add_test(suite, test_linked_list_last); |
universe@468 | 645 | cu_add_test(suite, test_linked_list_size); |
universe@468 | 646 | cu_add_test(suite, test_linked_list_sort); |
universe@455 | 647 | |
universe@459 | 648 | suite = CU_add_suite("high level linked list", NULL, NULL); |
universe@455 | 649 | |
universe@456 | 650 | cu_add_test(suite, test_hl_linked_list_create); |
universe@456 | 651 | cu_add_test(suite, test_hl_linked_list_add); |
universe@456 | 652 | cu_add_test(suite, test_hl_linked_list_last); |
universe@456 | 653 | cu_add_test(suite, test_hl_linked_list_insert); |
universe@456 | 654 | cu_add_test(suite, test_hl_linked_list_remove); |
universe@459 | 655 | cu_add_test(suite, test_hl_linked_list_find); |
universe@469 | 656 | cu_add_test(suite, test_hl_linked_list_sort); |
universe@413 | 657 | |
universe@466 | 658 | suite = CU_add_suite("high level pointer linked list", NULL, NULL); |
universe@466 | 659 | |
universe@466 | 660 | cu_add_test(suite, test_hl_ptr_linked_list_create); |
universe@466 | 661 | cu_add_test(suite, test_hl_ptr_linked_list_add); |
universe@466 | 662 | cu_add_test(suite, test_hl_ptr_linked_list_last); |
universe@466 | 663 | cu_add_test(suite, test_hl_ptr_linked_list_insert); |
universe@466 | 664 | cu_add_test(suite, test_hl_ptr_linked_list_remove); |
universe@466 | 665 | cu_add_test(suite, test_hl_ptr_linked_list_find); |
universe@469 | 666 | cu_add_test(suite, test_hl_ptr_linked_list_sort); |
universe@466 | 667 | |
universe@411 | 668 | CU_basic_set_mode(UCX_CU_BRM); |
universe@411 | 669 | |
universe@411 | 670 | int exitcode; |
universe@411 | 671 | if (CU_basic_run_tests()) { |
universe@411 | 672 | exitcode = CU_get_error(); |
universe@411 | 673 | } else { |
universe@411 | 674 | exitcode = CU_get_number_of_failures() == 0 ? 0 : 1; |
universe@411 | 675 | } |
universe@411 | 676 | CU_cleanup_registry(); |
universe@411 | 677 | return exitcode; |
universe@390 | 678 | } |