tests/test_list.c

changeset 1605
55b13f583356
parent 1604
68b75c091028
child 1606
f5883f6e42e7
--- a/tests/test_list.c	Sun Dec 14 16:21:09 2025 +0100
+++ b/tests/test_list.c	Sun Dec 14 17:30:17 2025 +0100
@@ -1394,7 +1394,7 @@
         CX_TEST_ASSERT(cxListAt(cxEmptyList, 0) == NULL);
         CX_TEST_ASSERT(cxListAt(cxEmptyList, 1) == NULL);
         // a "true" empty list
-        CxList *list = cxLinkedListCreateSimple(sizeof(int));
+        CxList *list = cxLinkedListCreate(NULL, sizeof(int));
         CX_TEST_ASSERT(cxListAt(list, 0) == NULL);
         CX_TEST_ASSERT(cxListAt(list, 1) == NULL);
         cxListFree(list);
@@ -1408,7 +1408,7 @@
         CX_TEST_ASSERT(cxListFind(cxEmptyList, &x) == 0);
         CX_TEST_ASSERT(cxListFindRemove(cxEmptyList, &y) == 0);
         // a "true" empty list
-        CxList *list = cxLinkedListCreateSimple(sizeof(int));
+        CxList *list = cxLinkedListCreate(NULL, sizeof(int));
         CX_TEST_ASSERT(cxListFind(list, &x) == 0);
         CX_TEST_ASSERT(cxListFindRemove(list, &y) == 0);
         cxListFree(list);
@@ -1417,8 +1417,8 @@
 
 CX_TEST(test_empty_list_compare) {
     CxList *empty = cxEmptyList;
-    CxList *ll = cxLinkedListCreateSimple(sizeof(int));
-    CxList *al = cxArrayListCreateSimple(sizeof(int), 8);
+    CxList *ll = cxLinkedListCreate(NULL, sizeof(int));
+    CxList *al = cxArrayListCreate(NULL, sizeof(int), 8);
     int x = 5;
     CX_TEST_DO {
         CX_TEST_ASSERT(0 == cxListCompare(empty, cxEmptyList));
@@ -1451,8 +1451,9 @@
     cx_testing_allocator_init(&talloc);
     CxAllocator *alloc = &talloc.base;
     CX_TEST_DO {
-        CxList *list = cxLinkedListCreate(alloc, cx_cmp_int, sizeof(int));
+        CxList *list = cxLinkedListCreate(alloc, sizeof(int));
         CX_TEST_ASSERT(list != NULL);
+        cxSetCompareFunc(list, cx_cmp_int);
         CX_TEST_ASSERT(list->collection.elem_size == sizeof(int));
         CX_TEST_ASSERT(list->collection.simple_destructor == NULL);
         CX_TEST_ASSERT(list->collection.advanced_destructor == NULL);
@@ -1468,7 +1469,7 @@
 }
 
 CX_TEST(test_list_ll_create_simple) {
-    CxList *list = cxLinkedListCreateSimple(sizeof(int));
+    CxList *list = cxLinkedListCreate(NULL, sizeof(int));
     CX_TEST_DO {
         CX_TEST_ASSERT(list != NULL);
         CX_TEST_ASSERT(list->collection.elem_size == sizeof(int));
@@ -1484,7 +1485,7 @@
 }
 
 CX_TEST(test_list_ll_create_simple_for_pointers) {
-    CxList *list = cxLinkedListCreateSimple(CX_STORE_POINTERS);
+    CxList *list = cxLinkedListCreate(NULL, CX_STORE_POINTERS);
     CX_TEST_DO {
         CX_TEST_ASSERT(list != NULL);
         CX_TEST_ASSERT(list->collection.elem_size == sizeof(void*));
@@ -1504,8 +1505,9 @@
     cx_testing_allocator_init(&talloc);
     CxAllocator *alloc = &talloc.base;
     CX_TEST_DO {
-        CxList *list = cxArrayListCreate(alloc, cx_cmp_int, sizeof(int), 8);
+        CxList *list = cxArrayListCreate(alloc, sizeof(int), 8);
         CX_TEST_ASSERT(list != NULL);
+        cxSetCompareFunc(list, cx_cmp_int);
         CX_TEST_ASSERT(list->collection.elem_size == sizeof(int));
         CX_TEST_ASSERT(list->collection.simple_destructor == NULL);
         CX_TEST_ASSERT(list->collection.advanced_destructor == NULL);
@@ -1521,7 +1523,7 @@
 }
 
 CX_TEST(test_list_arl_create_simple) {
-    CxList *list = cxArrayListCreateSimple(sizeof(int), 8);
+    CxList *list = cxArrayListCreate(NULL, sizeof(int), 8);
     CX_TEST_DO {
         CX_TEST_ASSERT(list != NULL);
         CX_TEST_ASSERT(list->collection.elem_size == sizeof(int));
@@ -1537,7 +1539,7 @@
 }
 
 CX_TEST(test_list_arl_create_simple_for_pointers) {
-    CxList *list = cxArrayListCreateSimple(CX_STORE_POINTERS, 8);
+    CxList *list = cxArrayListCreate(NULL, CX_STORE_POINTERS, 8);
     CX_TEST_DO {
         CX_TEST_ASSERT(list != NULL);
         CX_TEST_ASSERT(list->collection.elem_size == sizeof(void*));
@@ -1562,7 +1564,8 @@
     CxAllocator *alloc = &talloc.base;
     CX_TEST_DO {
         void *item = cxMalloc(alloc, sizeof(int));
-        CxList *list = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS);
+        CxList *list = cxLinkedListCreate(cxDefaultAllocator, CX_STORE_POINTERS);
+        cxSetCompareFunc(list, cx_cmp_int);
         cxListAdd(list, item);
         CX_TEST_ASSERT(!cx_testing_allocator_verify(&talloc));
         cxListFree(list);
@@ -1577,7 +1580,8 @@
 CX_TEST(test_list_pll_destroy_simple_destr) {
     CX_TEST_DO {
         int item = 0;
-        CxList *list = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS);
+        CxList *list = cxLinkedListCreate(cxDefaultAllocator, CX_STORE_POINTERS);
+        cxSetCompareFunc(list, cx_cmp_int);
         list->collection.simple_destructor = test_fake_simple_int_destr;
         cxListAdd(list, &item);
         cxListFree(list);
@@ -1591,7 +1595,8 @@
     CxAllocator *alloc = &talloc.base;
     CX_TEST_DO {
         void *item = cxMalloc(alloc, sizeof(int));
-        CxList *list = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS);
+        CxList *list = cxLinkedListCreate(cxDefaultAllocator, CX_STORE_POINTERS);
+        cxSetCompareFunc(list, cx_cmp_int);
         list->collection.destructor_data = alloc;
         list->collection.advanced_destructor = (cx_destructor_func2) cxFree;
         cxListAdd(list, item);
@@ -1608,7 +1613,8 @@
     CxAllocator *alloc = &talloc.base;
     CX_TEST_DO {
         void *item = cxMalloc(alloc, sizeof(int));
-        CxList *list = cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS, 4);
+        CxList *list = cxArrayListCreate(cxDefaultAllocator, CX_STORE_POINTERS, 4);
+        cxSetCompareFunc(list, cx_cmp_int);
         cxListAdd(list, item);
         CX_TEST_ASSERT(!cx_testing_allocator_verify(&talloc));
         cxListFree(list);
@@ -1623,7 +1629,8 @@
 CX_TEST(test_list_parl_destroy_simple_destr) {
     CX_TEST_DO {
         int item = 0;
-        CxList *list = cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS, 4);
+        CxList *list = cxArrayListCreate(cxDefaultAllocator, CX_STORE_POINTERS, 4);
+        cxSetCompareFunc(list, cx_cmp_int);
         list->collection.simple_destructor = test_fake_simple_int_destr;
         cxListAdd(list, &item);
         cxListFree(list);
@@ -1637,7 +1644,8 @@
     CxAllocator *alloc = &talloc.base;
     CX_TEST_DO {
         void *item = cxMalloc(alloc, sizeof(int));
-        CxList *list = cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS, 4);
+        CxList *list = cxArrayListCreate(cxDefaultAllocator, CX_STORE_POINTERS, 4);
+        cxSetCompareFunc(list, cx_cmp_int);
         list->collection.destructor_data = alloc;
         list->collection.advanced_destructor = (cx_destructor_func2) cxFree;
         cxListAdd(list, item);
@@ -1661,37 +1669,43 @@
 #define roll_out_test_invokers(name) \
 CX_TEST(test_list_ll_##name) { \
     set_up_combo \
-        CxList *list = cxLinkedListCreate(alloc, cx_cmp_int, sizeof(int)); \
+        CxList *list = cxLinkedListCreate(alloc, sizeof(int)); \
+        cxSetCompareFunc(list, cx_cmp_int); \
         CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, false); \
     tear_down_combo \
 } \
 CX_TEST(test_list_arl_##name) { \
     set_up_combo \
-        CxList *list = cxArrayListCreate(alloc, cx_cmp_int, sizeof(int), 8); \
+        CxList *list = cxArrayListCreate(alloc, sizeof(int), 8); \
+        cxSetCompareFunc(list, cx_cmp_int); \
         CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, false); \
     tear_down_combo \
 } \
 CX_TEST(test_list_kvl_##name) { \
     set_up_combo \
-        CxList *list = cxKvListCreate(alloc, cx_cmp_int, sizeof(int)); \
+        CxList *list = cxKvListCreate(alloc, sizeof(int)); \
+        cxSetCompareFunc(list, cx_cmp_int); \
         CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, false); \
     tear_down_combo \
 } \
 CX_TEST(test_list_pll_##name) { \
     set_up_combo \
-        CxList *list = cxLinkedListCreate(alloc, cx_cmp_int, CX_STORE_POINTERS); \
+        CxList *list = cxLinkedListCreate(alloc, CX_STORE_POINTERS); \
+        cxSetCompareFunc(list, cx_cmp_int); \
         CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, true); \
     tear_down_combo \
 } \
 CX_TEST(test_list_parl_##name) { \
     set_up_combo \
-        CxList *list = cxArrayListCreate(alloc, cx_cmp_int, CX_STORE_POINTERS, 8); \
+        CxList *list = cxArrayListCreate(alloc, CX_STORE_POINTERS, 8); \
+        cxSetCompareFunc(list, cx_cmp_int); \
         CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, true); \
     tear_down_combo \
 } \
 CX_TEST(test_list_pkvl_##name) { \
     set_up_combo \
-        CxList *list = cxKvListCreate(alloc, cx_cmp_int, CX_STORE_POINTERS); \
+        CxList *list = cxKvListCreate(alloc, CX_STORE_POINTERS); \
+        cxSetCompareFunc(list, cx_cmp_int); \
         CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, true); \
     tear_down_combo \
 }
@@ -1725,28 +1739,32 @@
 roll_out_test_invokers(name) \
 CX_TEST(test_list_llm_##name) { \
     set_up_combo \
-        CxList *list = cxLinkedListCreate(alloc, cx_cmp_int, sizeof(int)); \
+        CxList *list = cxLinkedListCreate(alloc, sizeof(int)); \
+        cxSetCompareFunc(list, cx_cmp_int); \
         do_set_default_class_funcs(list); \
         CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, false); \
     tear_down_combo \
 } \
 CX_TEST(test_list_arlm_##name) { \
     set_up_combo \
-        CxList *list = cxArrayListCreate(alloc, cx_cmp_int, sizeof(int), 8); \
+        CxList *list = cxArrayListCreate(alloc, sizeof(int), 8); \
+        cxSetCompareFunc(list, cx_cmp_int); \
         do_set_default_class_funcs(list); \
         CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, false); \
     tear_down_combo \
 } \
 CX_TEST(test_list_pllm_##name) { \
     set_up_combo \
-        CxList *list = cxLinkedListCreate(alloc, cx_cmp_int, CX_STORE_POINTERS); \
+        CxList *list = cxLinkedListCreate(alloc, CX_STORE_POINTERS); \
+        cxSetCompareFunc(list, cx_cmp_int); \
         do_set_default_class_funcs(list); \
         CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, true); \
     tear_down_combo \
 } \
 CX_TEST(test_list_parlm_##name) { \
     set_up_combo \
-        CxList *list = cxArrayListCreate(alloc, cx_cmp_int, CX_STORE_POINTERS, 8); \
+        CxList *list = cxArrayListCreate(alloc, CX_STORE_POINTERS, 8); \
+        cxSetCompareFunc(list, cx_cmp_int); \
         do_set_default_class_funcs(list); \
         CX_TEST_CALL_SUBROUTINE(test_list_verify_##name, list, true); \
     tear_down_combo \
@@ -2221,7 +2239,7 @@
 roll_out_test_combos(remove_array, {
     const size_t testdata_len = 32;
     int *testdata = int_test_data_added_to_list(list, isptrlist, testdata_len);
-    cxDefineDestructor(list, test_remove_array_destr);
+    cxSetDestructor(list, test_remove_array_destr);
     test_remove_array_destr_ctr = 0;
 
     // first, remove and get - no destructor must be called
@@ -2443,7 +2461,8 @@
     CxAllocator *alloc = &talloc.base;
     CX_TEST_DO {
         size_t item_size = 2*cx_array_swap_sbo_size;
-        CxList *list = cxArrayListCreate(alloc, cx_cmp_int, item_size, 8);
+        CxList *list = cxArrayListCreate(alloc, item_size, 8);
+        cxSetCompareFunc(list, cx_cmp_int);
 
         char *obj = malloc(item_size);
         for (char c = 'a' ; c <= 'z' ; c++) {
@@ -2643,6 +2662,7 @@
     const size_t len = 47; \
     int *testdata = int_test_data_added_to_list(list, isptrlist, len); \
     CxList *other = otherctr; \
+    cxSetCompareFunc(other, cx_cmp_int); \
     for (size_t i = 0; i < len; i++) cxListAdd(other, &testdata[i]); \
     CX_TEST_CALL_SUBROUTINE(test_list_verify_compare, list, other); \
     cxListFree(other); \
@@ -2650,25 +2670,26 @@
 })
 
 roll_out_compare_tests(
-        ll, cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, sizeof(int))
+        ll, cxLinkedListCreate(cxDefaultAllocator, sizeof(int))
 )
 
 roll_out_compare_tests(
-        pll, cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS)
+        pll, cxLinkedListCreate(cxDefaultAllocator, CX_STORE_POINTERS)
 )
 
 roll_out_compare_tests(
-        arl, cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, sizeof(int), 50)
+        arl, cxArrayListCreate(cxDefaultAllocator, sizeof(int), 50)
 )
 
 roll_out_compare_tests(
-        parl, cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS, 50)
+        parl, cxArrayListCreate(cxDefaultAllocator, CX_STORE_POINTERS, 50)
 )
 
 roll_out_test_combos_with_defaulted_funcs(compare_unoptimized, {
     const size_t len = 33;
     int *testdata = int_test_data_added_to_list(list, isptrlist, len);
-    CxList *other = cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, sizeof(int), 50);
+    CxList *other = cxArrayListCreate(cxDefaultAllocator, sizeof(int), 50);
+    cxSetCompareFunc(other, cx_cmp_int);
     do_set_default_class_funcs(other);
     for (size_t i = 0; i < len; i++) cxListAdd(other, &testdata[i]);
     CX_TEST_CALL_SUBROUTINE(test_list_verify_compare, list, other);
@@ -2738,7 +2759,7 @@
 roll_out_test_combos(simple_destr, {
     const size_t len = 60;
     int *testdata = int_test_data_added_to_list(list, isptrlist, len);
-    cxDefineDestructor(list, simple_destr_test_fun);
+    cxSetDestructor(list, simple_destr_test_fun);
     CX_TEST_CALL_SUBROUTINE(test_list_verify_destructor, list, testdata, len);
     free(testdata);
 })
@@ -2746,7 +2767,7 @@
 roll_out_test_combos(advanced_destr, {
     const size_t len = 75;
     int *testdata = int_test_data_added_to_list(list, isptrlist, len);
-    cxDefineAdvancedDestructor(list, advanced_destr_test_fun, NULL);
+    cxSetAdvancedDestructor(list, advanced_destr_test_fun, NULL);
     CX_TEST_CALL_SUBROUTINE(test_list_verify_destructor, list, testdata, len);
     free(testdata);
 })
@@ -2806,7 +2827,7 @@
 
     // register a destructor for the target list if it is storing pointers
     if (target_isptrlist) {
-        cxDefineAdvancedDestructor(target, cxFree, testing_alloc);
+        cxSetAdvancedDestructor(target, cxFree, testing_alloc);
     }
 
     // fill the source list
@@ -2853,7 +2874,7 @@
 
     // register a destructor for the target list if it is storing pointers
     if (target_isptrlist) {
-        cxDefineAdvancedDestructor(target, cxFree, testing_alloc);
+        cxSetAdvancedDestructor(target, cxFree, testing_alloc);
     }
 
     // fill the source list
@@ -2896,42 +2917,50 @@
 }
 
 roll_out_test_combos(clone_into_arl, {
-    CxList *target = cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, sizeof(int), 8);
+    CxList *target = cxArrayListCreate(cxDefaultAllocator, sizeof(int), 8);
+    cxSetCompareFunc(target, cx_cmp_int);
     CX_TEST_CALL_SUBROUTINE(verify_clone, target, list, false);
 })
 
 roll_out_test_combos(clone_into_ll, {
-    CxList *target = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, sizeof(int));
+    CxList *target = cxLinkedListCreate(cxDefaultAllocator, sizeof(int));
+    cxSetCompareFunc(target, cx_cmp_int);
     CX_TEST_CALL_SUBROUTINE(verify_clone, target, list, false);
 })
 
 roll_out_test_combos(clone_into_parl, {
-    CxList *target = cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS, 8);
+    CxList *target = cxArrayListCreate(cxDefaultAllocator, CX_STORE_POINTERS, 8);
+    cxSetCompareFunc(target, cx_cmp_int);
     CX_TEST_CALL_SUBROUTINE(verify_clone, target, list, true);
 })
 
 roll_out_test_combos(clone_into_pll, {
-    CxList *target = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS);
+    CxList *target = cxLinkedListCreate(cxDefaultAllocator, CX_STORE_POINTERS);
+    cxSetCompareFunc(target, cx_cmp_int);
     CX_TEST_CALL_SUBROUTINE(verify_clone, target, list, true);
 })
 
 roll_out_test_combos(clone_alloc_fail_into_arl, {
-    CxList *target = cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, sizeof(int), 8);
+    CxList *target = cxArrayListCreate(cxDefaultAllocator, sizeof(int), 8);
+    cxSetCompareFunc(target, cx_cmp_int);
     CX_TEST_CALL_SUBROUTINE(verify_clone_alloc_fail, target, list, false);
 })
 
 roll_out_test_combos(clone_alloc_fail_into_ll, {
-    CxList *target = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, sizeof(int));
+    CxList *target = cxLinkedListCreate(cxDefaultAllocator,  sizeof(int));
+    cxSetCompareFunc(target, cx_cmp_int);
     CX_TEST_CALL_SUBROUTINE(verify_clone_alloc_fail, target, list, false);
 })
 
 roll_out_test_combos(clone_alloc_fail_into_parl, {
-    CxList *target = cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS, 8);
+    CxList *target = cxArrayListCreate(cxDefaultAllocator,  CX_STORE_POINTERS, 8);
+    cxSetCompareFunc(target, cx_cmp_int);
     CX_TEST_CALL_SUBROUTINE(verify_clone_alloc_fail, target, list, true);
 })
 
 roll_out_test_combos(clone_alloc_fail_into_pll, {
-    CxList *target = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS);
+    CxList *target = cxLinkedListCreate(cxDefaultAllocator, CX_STORE_POINTERS);
+    cxSetCompareFunc(target, cx_cmp_int);
     CX_TEST_CALL_SUBROUTINE(verify_clone_alloc_fail, target, list, true);
 })
 
@@ -2939,10 +2968,13 @@
     CxTestingAllocator talloc;
     cx_testing_allocator_init(&talloc);
 
-    CxList *dst = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS);
-    cxDefineAdvancedDestructor(dst, cxFree, &talloc);
-    CxList *minuend = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, sizeof(int));
-    CxList *subtrahend = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, sizeof(int));
+    CxList *dst = cxLinkedListCreate(cxDefaultAllocator, CX_STORE_POINTERS);
+    cxSetAdvancedDestructor(dst, cxFree, &talloc);
+    CxList *minuend = cxLinkedListCreate(cxDefaultAllocator, sizeof(int));
+    CxList *subtrahend = cxLinkedListCreate(cxDefaultAllocator, sizeof(int));
+    cxSetCompareFunc(dst, cx_cmp_int);
+    cxSetCompareFunc(minuend, cx_cmp_int);
+    cxSetCompareFunc(subtrahend, cx_cmp_int);
 
     int dst_data[] = {47, 178, 176, 83};
     int minuend_data[] = {
@@ -2985,7 +3017,8 @@
         test_clone_func_max_clones = 30;
         expected_len = 34;
     }
-    CxList *expected = cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, sizeof(int), expected_len);
+    CxList *expected = cxArrayListCreate(cxDefaultAllocator, sizeof(int), expected_len);
+    cxSetCompareFunc(expected, cx_cmp_int);
     cxListAddArray(expected, sorted ? expected_sorted : expected_unsorted, expected_len);
 
     int result = cxListDifference(dst, minuend, subtrahend, test_clone_func, &talloc.base, NULL);
@@ -3034,10 +3067,13 @@
     CxTestingAllocator talloc;
     cx_testing_allocator_init(&talloc);
 
-    CxList *dst = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS);
-    cxDefineAdvancedDestructor(dst, cxFree, &talloc);
-    CxList *src = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, sizeof(int));
-    CxList *other = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, sizeof(int));
+    CxList *dst = cxLinkedListCreate(cxDefaultAllocator, CX_STORE_POINTERS);
+    cxSetAdvancedDestructor(dst, cxFree, &talloc);
+    CxList *src = cxLinkedListCreate(cxDefaultAllocator, sizeof(int));
+    CxList *other = cxLinkedListCreate(cxDefaultAllocator, sizeof(int));
+    cxSetCompareFunc(dst, cx_cmp_int);
+    cxSetCompareFunc(src, cx_cmp_int);
+    cxSetCompareFunc(other, cx_cmp_int);
 
     int dst_data[] = {47, 178, 176, 83};
     int src_data[] = {
@@ -3078,7 +3114,8 @@
         test_clone_func_max_clones = 10;
         expected_len = 14;
     }
-    CxList *expected = cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, sizeof(int), expected_len);
+    CxList *expected = cxArrayListCreate(cxDefaultAllocator, sizeof(int), expected_len);
+    cxSetCompareFunc(expected, cx_cmp_int);
     cxListAddArray(expected, sorted ? expected_sorted : expected_unsorted, expected_len);
 
     int result = cxListIntersection(dst, src, other, test_clone_func, &talloc.base, NULL);
@@ -3127,10 +3164,13 @@
     CxTestingAllocator talloc;
     cx_testing_allocator_init(&talloc);
 
-    CxList *dst = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS);
-    cxDefineAdvancedDestructor(dst, cxFree, &talloc);
-    CxList *src = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, sizeof(int));
-    CxList *other = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, sizeof(int));
+    CxList *dst = cxLinkedListCreate(cxDefaultAllocator, CX_STORE_POINTERS);
+    cxSetCompareFunc(dst, cx_cmp_int);
+    cxSetAdvancedDestructor(dst, cxFree, &talloc);
+    CxList *src = cxLinkedListCreate(cxDefaultAllocator, sizeof(int));
+    CxList *other = cxLinkedListCreate(cxDefaultAllocator, sizeof(int));
+    cxSetCompareFunc(src, cx_cmp_int);
+    cxSetCompareFunc(other, cx_cmp_int);
 
     int dst_data[] = {47, 178, 176, 83};
     int src_data[] = {
@@ -3183,7 +3223,8 @@
         test_clone_func_max_clones = 66;
         expected_len = 70;
     }
-    CxList *expected = cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, sizeof(int), expected_len);
+    CxList *expected = cxArrayListCreate(cxDefaultAllocator, sizeof(int), expected_len);
+    cxSetCompareFunc(expected, cx_cmp_int);
     cxListAddArray(expected, sorted ? expected_sorted : expected_unsorted, expected_len);
 
     int result = cxListUnion(dst, src, other, test_clone_func, &talloc.base, NULL);
@@ -3235,23 +3276,23 @@
     int c[] = {2, 4, 6, 8, 10, 12};
     int d[] = {4, 8, 12};
 
-    CxList *la = cxArrayListCreateSimple(sizeof(int), 8);
-    cxCollectionCompareFunc(la, cx_cmp_int);
+    CxList *la = cxArrayListCreate(NULL, sizeof(int), 8);
+    cxSetCompareFunc(la, cx_cmp_int);
     cxListInsertSortedArray(la, a, cx_nmemb(a));
-    CxList *lb = cxArrayListCreateSimple(sizeof(int), 8);
-    cxCollectionCompareFunc(lb, cx_cmp_int);
+    CxList *lb = cxArrayListCreate(NULL, sizeof(int), 8);
+    cxSetCompareFunc(lb, cx_cmp_int);
     cxListInsertSortedArray(lb, b, cx_nmemb(b));
-    CxList *lc = cxArrayListCreateSimple(sizeof(int), 8);
-    cxCollectionCompareFunc(lc, cx_cmp_int);
+    CxList *lc = cxArrayListCreate(NULL, sizeof(int), 8);
+    cxSetCompareFunc(lc, cx_cmp_int);
     cxListInsertSortedArray(lc, c, cx_nmemb(c));
-    CxList *ld = cxArrayListCreateSimple(sizeof(int), 8);
-    cxCollectionCompareFunc(ld, cx_cmp_int);
+    CxList *ld = cxArrayListCreate(NULL, sizeof(int), 8);
+    cxSetCompareFunc(ld, cx_cmp_int);
     cxListInsertSortedArray(ld, d, cx_nmemb(d));
 
-    CxList *d1 = cxArrayListCreateSimple(sizeof(int), 8);
-    cxCollectionCompareFunc(d1, cx_cmp_int);
-    CxList *d2 = cxArrayListCreateSimple(sizeof(int), 8);
-    cxCollectionCompareFunc(d2, cx_cmp_int);
+    CxList *d1 = cxArrayListCreate(NULL, sizeof(int), 8);
+    cxSetCompareFunc(d1, cx_cmp_int);
+    CxList *d2 = cxArrayListCreate(NULL, sizeof(int), 8);
+    cxSetCompareFunc(d2, cx_cmp_int);
 
     CX_TEST_DO {
         // clone a into d1
@@ -3262,7 +3303,7 @@
         // union of a (in d1) and b
         CX_TEST_ASSERT(0 == cxListUnionShallow(d2, d1, lb));
         CX_TEST_ASSERT(cxCollectionSorted(d2));
-        CxList *expected_union = cxArrayListCreateSimple(sizeof(int), 8);
+        CxList *expected_union = cxArrayListCreate(NULL, sizeof(int), 8);
         {
             int expected[] = {1, 2, 3, 5, 7, 8, 9, 10, 11};
             cxListAddArray(expected_union, expected, cx_nmemb(expected));
@@ -3274,7 +3315,7 @@
         cxListClear(d1);
         CX_TEST_ASSERT(0 == cxListIntersectionShallow(d1, d2, lc));
         CX_TEST_ASSERT(cxCollectionSorted(d1));
-        CxList *expected_intersection = cxArrayListCreateSimple(sizeof(int), 8);
+        CxList *expected_intersection = cxArrayListCreate(NULL, sizeof(int), 8);
         {
             int expected[] = {2, 8, 10};
             cxListAddArray(expected_intersection, expected, cx_nmemb(expected));
@@ -3286,7 +3327,7 @@
         cxListClear(d2);
         CX_TEST_ASSERT(0 == cxListDifferenceShallow(d2, d1, ld));
         CX_TEST_ASSERT(cxCollectionSorted(d2));
-        CxList *expected_difference = cxArrayListCreateSimple(sizeof(int), 8);
+        CxList *expected_difference = cxArrayListCreate(NULL, sizeof(int), 8);
         {
             int expected[] = {2, 10};
             cxListAddArray(expected_difference, expected, cx_nmemb(expected));
@@ -3304,7 +3345,8 @@
 }
 
 CX_TEST(test_list_pointer_list_supports_null) {
-    CxList *list = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, CX_STORE_POINTERS);
+    CxList *list = cxLinkedListCreate(cxDefaultAllocator, CX_STORE_POINTERS);
+    cxSetCompareFunc(list, cx_cmp_int);
     int x = 47;
     int y = 11;
     int z = 1337;
@@ -3332,9 +3374,12 @@
 }
 
 CX_TEST(test_list_use_insert_unique_to_remove_duplicates) {
-    CxList *linked_list = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, sizeof(int));
-    CxList *array_list = cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, sizeof(int), 8);
-    CxList *defaulted_list = cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, sizeof(int), 8);
+    CxList *linked_list = cxLinkedListCreate(cxDefaultAllocator, sizeof(int));
+    CxList *array_list = cxArrayListCreate(cxDefaultAllocator, sizeof(int), 8);
+    CxList *defaulted_list = cxArrayListCreate(cxDefaultAllocator, sizeof(int), 8);
+    cxSetCompareFunc(linked_list, cx_cmp_int);
+    cxSetCompareFunc(array_list, cx_cmp_int);
+    cxSetCompareFunc(defaulted_list, cx_cmp_int);
     do_set_default_class_funcs(defaulted_list);
     int test_array[23] = {
         120, -13, 100, -90, 13, -56, 74, 20, 28, 80, 18, -56, 130, 12, 15, 0, 39, 100, 0, 29, 28, 85, 20
@@ -3362,9 +3407,12 @@
 }
 
 CX_TEST(test_list_use_insert_unique_with_duplicates_in_source) {
-    CxList *linked_list = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_int, sizeof(int));
-    CxList *array_list = cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, sizeof(int), 8);
-    CxList *defaulted_list = cxArrayListCreate(cxDefaultAllocator, cx_cmp_int, sizeof(int), 8);
+    CxList *linked_list = cxLinkedListCreate(cxDefaultAllocator, sizeof(int));
+    CxList *array_list = cxArrayListCreate(cxDefaultAllocator, sizeof(int), 8);
+    CxList *defaulted_list = cxArrayListCreate(cxDefaultAllocator, sizeof(int), 8);
+    cxSetCompareFunc(linked_list, cx_cmp_int);
+    cxSetCompareFunc(array_list, cx_cmp_int);
+    cxSetCompareFunc(defaulted_list, cx_cmp_int);
     do_set_default_class_funcs(defaulted_list);
     int pre_filled[10] = {-13, 5, 18, 30, 40, 45, 50, 80, 85, 110};
     cxListInsertSortedArray(linked_list, pre_filled, 10);

mercurial