RList
|
00001 /* 00002 * Copyright (c) 2011, Stefan Götz <stefan.goetz@web.de> 00003 * 00004 * Permission to use, copy, modify, and/or distribute this software for any 00005 * purpose with or without fee is hereby granted, provided that the above 00006 * copyright notice and this permission notice appear in all copies. 00007 * 00008 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 00009 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 00010 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 00011 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 00012 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00013 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00014 * PERFORMANCE OF THIS SOFTWARE. 00015 */ 00016 00017 #include <stdlib.h> 00018 #include <string.h> 00019 #include <asm/signal.h> 00020 #include <check.h> 00021 00022 #include "rlist/single.h" 00023 00024 START_TEST(test_srl_init_valid) 00025 { 00026 struct srl_list list; 00027 struct srl_list cmp = SRL_INIT; 00028 00029 srl_init(&list, NULL); 00030 00031 fail_unless(list.node_count == cmp.node_count && list.free_fn == cmp.free_fn && list.head == cmp.head, NULL); 00032 } 00033 END_TEST 00034 00035 START_TEST(test_srl_init_valid_free_fn) 00036 { 00037 struct srl_list list; 00038 struct srl_list cmp = SRL_INIT_WITH(free); 00039 00040 srl_init(&list, free); 00041 00042 fail_unless(list.node_count == cmp.node_count && list.free_fn == cmp.free_fn && list.head == cmp.head, NULL); 00043 } 00044 END_TEST 00045 00046 START_TEST(test_srl_size_valid) 00047 { 00048 struct srl_list list = SRL_INIT; 00049 00050 fail_unless(srl_size(&list) == 0, NULL); 00051 } 00052 END_TEST 00053 00054 START_TEST(test_srl_first_empty) 00055 { 00056 struct srl_list list = SRL_INIT; 00057 struct srl_iterator iter; 00058 00059 fail_unless(srl_first(&list, &iter) == &iter, NULL); 00060 fail_unless(srl_is_eol(&iter), NULL); 00061 } 00062 END_TEST 00063 00064 START_TEST(test_srl_next_valid) 00065 { 00066 struct srl_list list = SRL_INIT; 00067 struct srl_iterator iter; 00068 00069 srl_first(&list, &iter); 00070 srl_insert_before(&iter, &list); 00071 srl_insert_before(&iter, &iter); 00072 00073 /* get the first node */ 00074 srl_first(&list, &iter); 00075 /* get the second node */ 00076 fail_unless(srl_next(&iter) == &iter, NULL); 00077 /* is this really the second node in terms of the payload? */ 00078 fail_unless(srl_payload(&iter) == &iter, NULL); 00079 /* since there are only two nodes, advance iter again to the end of list */ 00080 fail_unless(srl_next(&iter) == &iter, NULL); 00081 /* this must be the end of the list */ 00082 fail_unless(srl_is_eol(&iter), NULL); 00083 } 00084 END_TEST 00085 00086 START_TEST(test_srl_next_eol) 00087 { 00088 struct srl_list list = SRL_INIT; 00089 struct srl_iterator iter; 00090 00091 /* get the first node */ 00092 srl_first(&list, &iter); 00093 /* does srl_next() work? */ 00094 fail_unless(srl_next(&iter) == &iter, NULL); 00095 /* is this (again) the end of the list? */ 00096 fail_unless(srl_is_eol(&iter), NULL); 00097 } 00098 END_TEST 00099 00100 START_TEST(test_srl_insert_before_empty_list) 00101 { 00102 struct srl_list list = SRL_INIT; 00103 struct srl_iterator iter; 00104 00105 srl_first(&list, &iter); 00106 fail_unless(srl_insert_before(&iter, &iter), NULL); 00107 fail_unless(srl_size(&list) == 1, NULL); 00108 fail_unless(srl_is_eol(&iter), NULL); 00109 fail_unless(srl_payload(srl_first(&list, &iter)) == &iter, NULL); 00110 } 00111 END_TEST 00112 00113 START_TEST(test_srl_size_insert_before_reverse) 00114 { 00115 /* insert numbers in reverse order into a list and check that order */ 00116 unsigned numbers[] = { 0, 1, 2 , 3, 4, 5, 6, 7 }; 00117 const unsigned SIZE = sizeof(numbers) / sizeof(*numbers); 00118 struct srl_iterator iter; 00119 struct srl_list list = SRL_INIT; 00120 00121 for (unsigned idx = 0; idx < SIZE; idx += 1) { 00122 /* sanity check */ 00123 fail_unless(srl_size(&list) == idx, NULL); 00124 /* get the first node to insert at the list head */ 00125 srl_first(&list, &iter); 00126 /* insert the number at idx */ 00127 fail_unless(srl_insert_before(&iter, &numbers[idx]), NULL); 00128 /* sanity check */ 00129 fail_unless(srl_size(&list) == (idx + 1), NULL); 00130 00131 /* get the first node to check it */ 00132 srl_first(&list, &iter); 00133 /* check the payload pointer */ 00134 fail_unless(srl_payload(&iter) == &numbers[idx], NULL); 00135 } 00136 00137 /* get the first node to iterate from the list head */ 00138 srl_first(&list, &iter); 00139 /* do another pass over the list to check whether it has the intended order */ 00140 for (int idx = SIZE - 1; idx >= 0; idx -= 1) { 00141 /* check the payload pointer */ 00142 fail_unless(srl_payload(&iter) == &numbers[idx], NULL); 00143 /* get the next node to check it */ 00144 srl_next(&iter); 00145 } 00146 /* sanity check: are we at the end of the list as expected? */ 00147 fail_unless(srl_is_eol(&iter), NULL); 00148 } 00149 END_TEST 00150 00151 START_TEST(test_srl_size_insert_before_forward) 00152 { 00153 /* insert numbers into a list and check their order */ 00154 unsigned numbers[] = { 0, 1, 2 , 3, 4, 5, 6, 7 }; 00155 const unsigned SIZE = sizeof(numbers) / sizeof(*numbers); 00156 struct srl_iterator iter; 00157 struct srl_list list = SRL_INIT; 00158 00159 /* get the first node to insert the first element */ 00160 srl_first(&list, &iter); 00161 for (unsigned idx = 0; idx < SIZE; idx += 1) { 00162 /* sanity check */ 00163 fail_unless(srl_size(&list) == idx, NULL); 00164 /* sanity check: we expect iter to always refer to the end of the list */ 00165 fail_unless(srl_is_eol(&iter), NULL); 00166 /* insert the number at idx */ 00167 fail_unless(srl_insert_before(&iter, &numbers[idx]), NULL); 00168 /* sanity check */ 00169 fail_unless(srl_size(&list) == (idx + 1), NULL); 00170 } 00171 00172 /* get the first node to iterate from the list head */ 00173 srl_first(&list, &iter); 00174 /* do another pass over the list to check whether it has the intended order */ 00175 for (unsigned idx = 0; idx < SIZE; idx += 1) { 00176 /* check the payload pointer */ 00177 fail_unless(srl_payload(&iter) == &numbers[idx], NULL); 00178 /* get the next node to check it */ 00179 srl_next(&iter); 00180 } 00181 /* sanity check: are we at the end of the list as expected? */ 00182 fail_unless(srl_is_eol(&iter), NULL); 00183 } 00184 END_TEST 00185 00186 START_TEST(test_srl_size_del_first) 00187 { 00188 const unsigned SIZE = 16; 00189 struct srl_iterator iter; 00190 struct srl_list list = SRL_INIT_WITH(free); 00191 00192 for (unsigned i = 0; i < SIZE; i += 1) { 00193 srl_insert_before(srl_first(&list, &iter), malloc(4)); 00194 } 00195 for (unsigned i = SIZE; i > 0; i -= 1) { 00196 fail_unless(srl_size(&list) == i, NULL); 00197 fail_unless(srl_del(srl_first(&list, &iter)) == NULL, NULL); 00198 fail_unless(srl_size(&list) == (i - 1), NULL); 00199 } 00200 } 00201 END_TEST 00202 00203 START_TEST(test_srl_size_del_iterate) 00204 { 00205 const unsigned SIZE = 16; 00206 struct srl_iterator iter; 00207 struct srl_list list = SRL_INIT_WITH(free); 00208 00209 for (unsigned i = 0; i < SIZE; i += 1) { 00210 srl_insert_before(srl_first(&list, &iter), malloc(4)); 00211 } 00212 srl_first(&list, &iter); 00213 for (unsigned i = 0; i < SIZE; i += 1) { 00214 fail_unless(srl_del(&iter) == NULL, NULL); 00215 fail_unless(srl_next(&iter) == &iter, NULL); 00216 } 00217 fail_unless(srl_size(&list) == 0, NULL); 00218 } 00219 END_TEST 00220 00221 static void reset_number(void *const payload) 00222 { 00223 *(unsigned *) payload = 0; 00224 } 00225 00226 START_TEST(test_srl_insert_before_first_next_payload_del_valid) 00227 { 00228 unsigned numbers[16]; 00229 const unsigned SIZE = sizeof(numbers) / sizeof(numbers[0]); 00230 struct srl_list list = SRL_INIT_WITH(reset_number); 00231 struct srl_iterator iter; 00232 struct srl_iterator *tmp; 00233 unsigned i; 00234 00235 // fill the numbers array slots with their respective index 00236 for (i = 0; i < SIZE; i += 1) { 00237 numbers[i] = i; 00238 } 00239 00240 // add numbers from 0..SIZE in reverse order to the list 00241 for (i = 0; i < SIZE; i += 1) { 00242 void *payload; 00243 00244 fail_unless(srl_insert_before(srl_first(&list, &iter), &numbers[i]), NULL); 00245 // check that the first list element looks as expected 00246 fail_unless(srl_first(&list, &iter) != NULL, NULL); 00247 fail_unless((payload = srl_payload(&iter)) != NULL, NULL); 00248 fail_unless(payload == &numbers[i]); 00249 fail_unless(*(unsigned *) payload == numbers[i]); 00250 } 00251 00252 // iterate through the list and check whether the nodes refer to the 00253 // numbers array in reverse order 00254 i = SIZE - 1; 00255 for (tmp = srl_first(&list, &iter); !srl_is_eol(tmp); srl_next(tmp)) { 00256 void *payload; 00257 00258 fail_unless((payload = srl_payload(&iter)) != NULL, NULL); 00259 fail_unless(payload == &numbers[i]); 00260 fail_unless(*(unsigned *) payload == numbers[i]); 00261 00262 i -= 1; 00263 } 00264 00265 // iterate through the list and check whether nodes can be deleted in the 00266 // iteration and if the registered call-back function is called 00267 i = SIZE - 1; 00268 for (tmp = srl_first(&list, &iter); !srl_is_eol(tmp); srl_next(tmp)) { 00269 fail_unless(numbers[i] == i, NULL); 00270 fail_unless(srl_del(&iter) == NULL, NULL); 00271 fail_unless(numbers[i] == 0, NULL); 00272 00273 i -= 1; 00274 } 00275 00276 fail_unless(srl_size(&list) == 0, NULL); 00277 } 00278 END_TEST 00279 00280 START_TEST(test_srl_insert_before_null_payload) 00281 { 00282 struct srl_list list = SRL_INIT_WITH(free); 00283 struct srl_iterator iter; 00284 00285 fail_unless(srl_insert_before(srl_first(&list, &iter), NULL), NULL); 00286 // check that the first list element looks as expected 00287 fail_unless(srl_first(&list, &iter) != NULL, NULL); 00288 fail_unless(srl_payload(&iter) == NULL, NULL); 00289 } 00290 END_TEST 00291 00292 START_TEST(test_srl_del_all_valid) 00293 { 00294 const unsigned SIZE = 16; 00295 struct srl_iterator iter; 00296 struct srl_list list = SRL_INIT_WITH(free); 00297 00298 srl_first(&list, &iter); 00299 for (unsigned i = 0; i < SIZE; i += 1) { 00300 fail_unless(srl_insert_before(&iter, malloc(4)), NULL); 00301 } 00302 fail_unless(srl_size(&list) == SIZE, NULL); 00303 srl_del_all(&list); 00304 fail_unless(srl_size(&list) == 0, NULL); 00305 fail_unless(srl_is_eol(srl_first(&list, &iter)), NULL); 00306 } 00307 END_TEST 00308 00309 static bool match_unsigned(void *const payload, 00310 void *const context) 00311 { 00312 return *(unsigned *)payload == *(unsigned *)context; 00313 } 00314 00315 START_TEST(test_srl_find_valid) 00316 { 00317 unsigned numbers[] = { 0, 1, 2, 3, 4, 5, 6, 0 }; 00318 unsigned needle = 0; 00319 struct srl_iterator iter; 00320 struct srl_list list = SRL_INIT; 00321 00322 // append numbers in ascending order 00323 srl_first(&list, &iter); 00324 for (unsigned idx = 0; idx < sizeof(numbers) / sizeof(numbers[0]); idx += 1) { 00325 srl_insert_before(&iter, &numbers[idx]); 00326 } 00327 00328 srl_first(&list, &iter); 00329 // does srl_find() return a non-NULL value as advertised? 00330 fail_unless(srl_find(&iter, match_unsigned, &needle) != NULL, NULL); 00331 // srl_find() should find something 00332 fail_unless(!srl_is_eol(&iter), NULL); 00333 // srl_find() should find the correct number 00334 fail_unless(srl_payload(&iter) == &numbers[0], NULL); 00335 00336 // go to the next list node 00337 srl_next(&iter); 00338 // does srl_find() return iter as advertised? 00339 fail_unless(srl_find(&iter, match_unsigned, &needle) == &iter, NULL); 00340 // srl_find() should find something 00341 fail_unless(!srl_is_eol(&iter), NULL); 00342 // srl_find() should find the correct number 00343 fail_unless(srl_payload(&iter) == &numbers[7], NULL); 00344 00345 // go to the next list node (i.e., EOL) 00346 srl_next(&iter); 00347 // does srl_find() return iter as advertised? 00348 fail_unless(srl_find(&iter, match_unsigned, &needle) == &iter, NULL); 00349 // srl_find() should not find anything 00350 fail_unless(srl_is_eol(&iter), NULL); 00351 00352 needle = 2; 00353 srl_first(&list, &iter); 00354 // does srl_find() return iter as advertised? 00355 fail_unless(srl_find(&iter, match_unsigned, &needle) == &iter, NULL); 00356 // srl_find() should find something 00357 fail_unless(!srl_is_eol(&iter), NULL); 00358 // srl_find() should find the correct number 00359 fail_unless(srl_payload(&iter) == &numbers[needle], NULL); 00360 00361 // go to the next list node 00362 srl_next(&iter); 00363 // does srl_find() return iter as advertised? 00364 fail_unless(srl_find(&iter, match_unsigned, &needle) == &iter, NULL); 00365 // srl_find() should not find anything 00366 fail_unless(srl_is_eol(&iter), NULL); 00367 } 00368 END_TEST 00369 00370 START_TEST(test_srl_find_payload_valid) 00371 { 00372 unsigned numbers[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; 00373 struct srl_iterator iter; 00374 struct srl_list list = SRL_INIT; 00375 00376 // append numbers in ascending order 00377 srl_first(&list, &iter); 00378 for (unsigned idx = 0; idx < sizeof(numbers) / sizeof(numbers[0]); idx += 1) { 00379 srl_insert_before(&iter, &numbers[idx]); 00380 } 00381 00382 // find '0' from list head 00383 srl_first(&list, &iter); 00384 // does srl_find_payload() return iter as advertised? 00385 fail_unless(srl_find_payload(&iter, &numbers[0]) == &iter, NULL); 00386 // srl_find_payload() should find something 00387 fail_unless(!srl_is_eol(&iter), NULL); 00388 // srl_find_payload() should find the correct number 00389 fail_unless(srl_payload(&iter) == &numbers[0], NULL); 00390 00391 // find '2' from '0' (== list head) 00392 // does srl_find_payload() return iter as advertised? 00393 fail_unless(srl_find_payload(&iter, &numbers[2]) == &iter, NULL); 00394 // srl_find_payload() should find something 00395 fail_unless(!srl_is_eol(&iter), NULL); 00396 // srl_find_payload() should find the correct number 00397 fail_unless(srl_payload(&iter) == &numbers[2], NULL); 00398 00399 // find '0' from '2' 00400 // does srl_find_payload() return iter as advertised? 00401 fail_unless(srl_find_payload(&iter, &numbers[0]) == &iter, NULL); 00402 // srl_find_payload() should not find anything 00403 fail_unless(srl_is_eol(&iter), NULL); 00404 00405 // find '7' (last node) from list head 00406 srl_first(&list, &iter); 00407 // does srl_find_payload() return iter as advertised? 00408 fail_unless(srl_find_payload(&iter, &numbers[7]) == &iter, NULL); 00409 // srl_find_payload() should find something 00410 fail_unless(!srl_is_eol(&iter), NULL); 00411 // srl_find_payload() should find the correct number 00412 fail_unless(srl_payload(&iter) == &numbers[7], NULL); 00413 00414 // find NULL 00415 srl_first(&list, &iter); 00416 // does srl_find_payload() return iter as advertised? 00417 fail_unless(srl_find_payload(&iter, NULL) == &iter, NULL); 00418 // srl_find_payload() should not find anything 00419 fail_unless(srl_is_eol(&iter), NULL); 00420 00421 // find pointer not in list 00422 srl_first(&list, &iter); 00423 // does srl_find_payload() return iter as advertised? 00424 fail_unless(srl_find_payload(&iter, &iter) == &iter, NULL); 00425 // srl_find_payload() should not find anything 00426 fail_unless(srl_is_eol(&iter), NULL); 00427 } 00428 END_TEST 00429 00430 static int map_multiply(struct srl_iterator *const iter, 00431 void *const context) 00432 { 00433 unsigned *const number = srl_payload(iter); 00434 unsigned *const sum = context; 00435 00436 *number *= 3; 00437 *sum += *number; 00438 00439 return 0; 00440 } 00441 00442 static int map_return_one(__attribute__ ((unused)) struct srl_iterator *const iter, 00443 __attribute__ ((unused)) void *const context) 00444 { 00445 return 1; 00446 } 00447 00448 static bool match_first_two(__attribute__ ((unused)) void *const payload, 00449 __attribute__ ((unused)) void *const context) 00450 { 00451 static unsigned invocations = 0; 00452 invocations += 1; 00453 return invocations <= 2; 00454 } 00455 00456 START_TEST(test_srl_map_valid) 00457 { 00458 unsigned numbers[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; 00459 unsigned sum = 0; 00460 struct srl_iterator iter; 00461 struct srl_list list = SRL_INIT; 00462 00463 // append numbers in ascending order 00464 srl_first(&list, &iter); 00465 for (unsigned idx = 0; idx < sizeof(numbers) / sizeof(numbers[0]); idx += 1) { 00466 srl_insert_before(&iter, &numbers[idx]); 00467 } 00468 00469 // multiply the values of all list nodes by 3 and store the total in sum 00470 fail_unless(srl_map(srl_first(&list, &iter), map_multiply, &sum, NULL, NULL) == 0, NULL); 00471 // map should have covered the whole list 00472 fail_unless(srl_is_eol(&iter), NULL); 00473 // all numbers in the array should have been multiplied by three 00474 for (unsigned idx = 0; idx < sizeof(numbers) / sizeof(numbers[0]); idx += 1) { 00475 fail_unless(numbers[idx] == idx * 3, NULL); 00476 } 00477 // the sum of the array elements should have been correctly computed by the map function 00478 fail_unless(sum == 84, NULL); 00479 00480 sum = 0; 00481 // multiply the value of only the second and third list node and store the total sum 00482 fail_unless(srl_map(srl_next(srl_first(&list, &iter)), map_multiply, &sum, match_first_two, NULL) == 0, NULL); 00483 // map should have covered the whole list 00484 fail_unless(srl_is_eol(&iter), NULL); 00485 // the second and third number in the array should have been multiplied by three 00486 fail_unless(numbers[0] == 0); 00487 for (unsigned idx = 1; idx < 3; idx += 1) { 00488 fail_unless(numbers[idx] == idx * 9, NULL); 00489 } 00490 for (unsigned idx = 3; idx < sizeof(numbers) / sizeof(numbers[0]); idx += 1) { 00491 fail_unless(numbers[idx] == idx * 3, NULL); 00492 } 00493 // the sum of the array elements should have been correctly computed by the map function 00494 fail_unless(sum == 27, NULL); 00495 00496 // does map() return the value the map callback function returns? 00497 fail_unless(srl_map(srl_first(&list, &iter), map_return_one, NULL, NULL, NULL) == 1, NULL); 00498 } 00499 END_TEST 00500 00501 #ifndef NDEBUG // The following tests rely on assertions being enabled 00502 START_TEST(test_srl_init_null) 00503 { 00504 srl_init(NULL, NULL); 00505 } 00506 END_TEST 00507 00508 START_TEST(test_srl_size_null) 00509 { 00510 srl_size(NULL); 00511 } 00512 END_TEST 00513 00514 START_TEST(test_srl_insert_before_null_iter) 00515 { 00516 srl_insert_before(NULL, NULL); 00517 } 00518 END_TEST 00519 00520 START_TEST(test_srl_first_null_list) 00521 { 00522 struct srl_iterator i; 00523 srl_first(NULL, &i); 00524 } 00525 END_TEST 00526 00527 START_TEST(test_srl_first_null_iter) 00528 { 00529 struct srl_list l = SRL_INIT; 00530 00531 srl_first(&l, NULL); 00532 } 00533 END_TEST 00534 00535 START_TEST(test_srl_next_null) 00536 { 00537 srl_next(NULL); 00538 } 00539 END_TEST 00540 00541 START_TEST(test_srl_del_null) 00542 { 00543 srl_del(NULL); 00544 } 00545 END_TEST 00546 00547 START_TEST(test_srl_del_eol) 00548 { 00549 struct srl_list l = SRL_INIT; 00550 struct srl_iterator i; 00551 00552 srl_del(srl_first(&l, &i)); 00553 } 00554 END_TEST 00555 00556 START_TEST(test_srl_del_all_null) 00557 { 00558 srl_del_all(NULL); 00559 } 00560 END_TEST 00561 00562 START_TEST(test_srl_find_iter_null) 00563 { 00564 srl_find(NULL, match_unsigned, NULL); 00565 } 00566 END_TEST 00567 00568 START_TEST(test_srl_find_match_fn_null) 00569 { 00570 struct srl_list list = SRL_INIT; 00571 struct srl_iterator iter; 00572 00573 srl_find(srl_first(&list, &iter), NULL, NULL); 00574 } 00575 END_TEST 00576 00577 START_TEST(test_srl_find_payload_iter_null) 00578 { 00579 srl_find_payload(NULL, NULL); 00580 } 00581 END_TEST 00582 00583 START_TEST(test_srl_map_iter_null) 00584 { 00585 unsigned sum = 0; 00586 00587 srl_map(NULL, map_multiply, &sum, match_first_two, NULL); 00588 } 00589 END_TEST 00590 00591 START_TEST(test_srl_map_map_fn_null) 00592 { 00593 struct srl_list list = SRL_INIT; 00594 struct srl_iterator iter; 00595 srl_map(srl_first(&list, &iter), NULL, NULL, match_first_two, NULL); 00596 } 00597 END_TEST 00598 #endif // NDEBUG 00599 00600 Suite *single(void); 00601 00602 Suite *single(void) 00603 { 00604 Suite *s = suite_create("single"); 00605 00606 TCase *tc_core = tcase_create("Core"); 00607 tcase_add_test(tc_core, test_srl_init_valid); 00608 tcase_add_test(tc_core, test_srl_init_valid_free_fn); 00609 tcase_add_test(tc_core, test_srl_size_valid); 00610 tcase_add_test(tc_core, test_srl_first_empty); 00611 tcase_add_test(tc_core, test_srl_next_valid); 00612 tcase_add_test(tc_core, test_srl_next_eol); 00613 tcase_add_test(tc_core, test_srl_insert_before_empty_list); 00614 tcase_add_test(tc_core, test_srl_size_insert_before_reverse); 00615 tcase_add_test(tc_core, test_srl_size_insert_before_forward); 00616 tcase_add_test(tc_core, test_srl_size_del_first); 00617 tcase_add_test(tc_core, test_srl_size_del_iterate); 00618 tcase_add_test(tc_core, test_srl_insert_before_first_next_payload_del_valid); 00619 tcase_add_test(tc_core, test_srl_insert_before_null_payload); 00620 tcase_add_test(tc_core, test_srl_del_all_valid); 00621 tcase_add_test(tc_core, test_srl_find_valid); 00622 tcase_add_test(tc_core, test_srl_find_payload_valid); 00623 tcase_add_test(tc_core, test_srl_map_valid); 00624 00625 #ifndef NDEBUG // The following tests rely on assertions being enabled 00626 tcase_add_test_raise_signal(tc_core, test_srl_init_null, SIGABRT); 00627 tcase_add_test_raise_signal(tc_core, test_srl_size_null, SIGABRT); 00628 tcase_add_test_raise_signal(tc_core, test_srl_insert_before_null_iter, SIGABRT); 00629 tcase_add_test_raise_signal(tc_core, test_srl_first_null_list, SIGABRT); 00630 tcase_add_test_raise_signal(tc_core, test_srl_first_null_iter, SIGABRT); 00631 tcase_add_test_raise_signal(tc_core, test_srl_next_null, SIGABRT); 00632 tcase_add_test_raise_signal(tc_core, test_srl_del_null, SIGABRT); 00633 tcase_add_test_raise_signal(tc_core, test_srl_del_eol, SIGABRT); 00634 tcase_add_test_raise_signal(tc_core, test_srl_del_all_null, SIGABRT); 00635 tcase_add_test_raise_signal(tc_core, test_srl_find_iter_null, SIGABRT); 00636 tcase_add_test_raise_signal(tc_core, test_srl_find_match_fn_null, SIGABRT); 00637 tcase_add_test_raise_signal(tc_core, test_srl_find_payload_iter_null, SIGABRT); 00638 tcase_add_test_raise_signal(tc_core, test_srl_map_iter_null, SIGABRT); 00639 tcase_add_test_raise_signal(tc_core, test_srl_map_map_fn_null, SIGABRT); 00640 #endif // NDEBUG 00641 00642 suite_add_tcase(s, tc_core); 00643 00644 return s; 00645 }