tests/test_list.c

changeset 1350
189756516eaa
parent 1321
1003c014bf92
equal deleted inserted replaced
1349:b1696d0d598b 1350:189756516eaa
30 #include "util_allocator.h" 30 #include "util_allocator.h"
31 #include "cx/compare.h" 31 #include "cx/compare.h"
32 32
33 #include "cx/array_list.h" 33 #include "cx/array_list.h"
34 #include "cx/linked_list.h" 34 #include "cx/linked_list.h"
35 #include "cx/kv_list.h"
35 36
36 #include <stdarg.h> 37 #include <stdarg.h>
37 #include <errno.h> 38 #include <errno.h>
38 39
39 CX_TEST(test_array_add) { 40 CX_TEST(test_array_add) {
1240 set_up_combo \ 1241 set_up_combo \
1241 CxList *list = cxArrayListCreate(alloc, cx_cmp_int, sizeof(int), 8); \ 1242 CxList *list = cxArrayListCreate(alloc, cx_cmp_int, sizeof(int), 8); \
1242 CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, false); \ 1243 CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, false); \
1243 tear_down_combo \ 1244 tear_down_combo \
1244 } \ 1245 } \
1246 CX_TEST(test_list_kvl_##name) { \
1247 set_up_combo \
1248 CxList *list = cxKvListCreate(alloc, cx_cmp_int, sizeof(int)); \
1249 CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, false); \
1250 tear_down_combo \
1251 } \
1245 CX_TEST(test_list_pll_##name) { \ 1252 CX_TEST(test_list_pll_##name) { \
1246 set_up_combo \ 1253 set_up_combo \
1247 CxList *list = cxLinkedListCreate(alloc, cx_cmp_int, CX_STORE_POINTERS); \ 1254 CxList *list = cxLinkedListCreate(alloc, cx_cmp_int, CX_STORE_POINTERS); \
1248 CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, true); \ 1255 CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, true); \
1249 tear_down_combo \ 1256 tear_down_combo \
1250 } \ 1257 } \
1251 CX_TEST(test_list_parl_##name) { \ 1258 CX_TEST(test_list_parl_##name) { \
1252 set_up_combo \ 1259 set_up_combo \
1253 CxList *list = cxArrayListCreate(alloc, cx_cmp_int, CX_STORE_POINTERS, 8); \ 1260 CxList *list = cxArrayListCreate(alloc, cx_cmp_int, CX_STORE_POINTERS, 8); \
1261 CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, true); \
1262 tear_down_combo \
1263 } \
1264 CX_TEST(test_list_pkvl_##name) { \
1265 set_up_combo \
1266 CxList *list = cxKvListCreate(alloc, cx_cmp_int, CX_STORE_POINTERS); \
1254 CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, true); \ 1267 CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, true); \
1255 tear_down_combo \ 1268 tear_down_combo \
1256 } 1269 }
1257 #define roll_out_test_combos(name, body) \ 1270 #define roll_out_test_combos(name, body) \
1258 static CX_TEST_SUBROUTINE(test_list_verify_##name, CxList *list, \ 1271 static CX_TEST_SUBROUTINE(test_list_verify_##name, CxList *list, \
2324 cx_test_register(suite, test_list_pllm_compare_unoptimized); 2337 cx_test_register(suite, test_list_pllm_compare_unoptimized);
2325 2338
2326 return suite; 2339 return suite;
2327 } 2340 }
2328 2341
2342 CxTestSuite *cx_test_suite_kv_list(void) {
2343 CxTestSuite *suite = cx_test_suite_new("kv_list");
2344
2345 cx_test_register(suite, test_list_kvl_add);
2346 cx_test_register(suite, test_list_pkvl_add);
2347 cx_test_register(suite, test_list_kvl_insert);
2348 cx_test_register(suite, test_list_pkvl_insert);
2349 cx_test_register(suite, test_list_kvl_emplace);
2350 cx_test_register(suite, test_list_pkvl_emplace);
2351 cx_test_register(suite, test_list_kvl_insert_array);
2352 cx_test_register(suite, test_list_pkvl_insert_array);
2353 cx_test_register(suite, test_list_kvl_insert_sorted);
2354 cx_test_register(suite, test_list_pkvl_insert_sorted);
2355 cx_test_register(suite, test_list_kvl_remove);
2356 cx_test_register(suite, test_list_pkvl_remove);
2357 cx_test_register(suite, test_list_kvl_remove_and_get);
2358 cx_test_register(suite, test_list_pkvl_remove_and_get);
2359 cx_test_register(suite, test_list_kvl_remove_array);
2360 cx_test_register(suite, test_list_pkvl_remove_array);
2361 cx_test_register(suite, test_list_kvl_find_remove);
2362 cx_test_register(suite, test_list_pkvl_find_remove);
2363 cx_test_register(suite, test_list_kvl_find_remove_sorted);
2364 cx_test_register(suite, test_list_pkvl_find_remove_sorted);
2365 cx_test_register(suite, test_list_kvl_contains);
2366 cx_test_register(suite, test_list_pkvl_contains);
2367 cx_test_register(suite, test_list_kvl_clear);
2368 cx_test_register(suite, test_list_pkvl_clear);
2369 cx_test_register(suite, test_list_kvl_at);
2370 cx_test_register(suite, test_list_pkvl_at);
2371 cx_test_register(suite, test_list_kvl_set);
2372 cx_test_register(suite, test_list_pkvl_set);
2373 cx_test_register(suite, test_list_kvl_swap);
2374 cx_test_register(suite, test_list_pkvl_swap);
2375 cx_test_register(suite, test_list_kvl_find);
2376 cx_test_register(suite, test_list_pkvl_find);
2377 cx_test_register(suite, test_list_kvl_sort);
2378 cx_test_register(suite, test_list_pkvl_sort);
2379 cx_test_register(suite, test_list_kvl_reverse);
2380 cx_test_register(suite, test_list_pkvl_reverse);
2381 cx_test_register(suite, test_list_kvl_iterator);
2382 cx_test_register(suite, test_list_pkvl_iterator);
2383 cx_test_register(suite, test_list_kvl_insert_with_iterator);
2384 cx_test_register(suite, test_list_pkvl_insert_with_iterator);
2385 cx_test_register(suite, test_list_kvl_compare_ll);
2386 cx_test_register(suite, test_list_kvl_compare_arl);
2387 cx_test_register(suite, test_list_kvl_compare_pll);
2388 cx_test_register(suite, test_list_kvl_compare_parl);
2389 cx_test_register(suite, test_list_pkvl_compare_ll);
2390 cx_test_register(suite, test_list_pkvl_compare_arl);
2391 cx_test_register(suite, test_list_pkvl_compare_pll);
2392 cx_test_register(suite, test_list_pkvl_compare_parl);
2393 cx_test_register(suite, test_list_kvl_simple_destr);
2394 cx_test_register(suite, test_list_pkvl_simple_destr);
2395 cx_test_register(suite, test_list_kvl_advanced_destr);
2396 cx_test_register(suite, test_list_pkvl_advanced_destr);
2397
2398 return suite;
2399 }
2400
2329 CxTestSuite *cx_test_suite_empty_list(void) { 2401 CxTestSuite *cx_test_suite_empty_list(void) {
2330 CxTestSuite *suite = cx_test_suite_new("empty list dummy"); 2402 CxTestSuite *suite = cx_test_suite_new("empty list dummy");
2331 2403
2332 cx_test_register(suite, test_empty_list_size); 2404 cx_test_register(suite, test_empty_list_size);
2333 cx_test_register(suite, test_empty_list_iterator); 2405 cx_test_register(suite, test_empty_list_iterator);

mercurial