tests/test_list.c

changeset 1618
ef7cab6eb131
parent 1616
bdc04a8e0dd3
--- a/tests/test_list.c	Tue Dec 16 21:33:58 2025 +0100
+++ b/tests/test_list.c	Wed Dec 17 19:05:50 2025 +0100
@@ -491,24 +491,24 @@
         int s;
         s = 2;
         node *n = list;
-        CX_TEST_ASSERT(cx_linked_list_find(list, loc_next, loc_data, cx_cmp_int, &s, &i) == n);
+        CX_TEST_ASSERT(cx_linked_list_find(list, loc_next, loc_data, &s, &i, cx_cmp_int) == n);
         CX_TEST_ASSERT(i == 0);
         n = n->next;
         s = 4;
-        CX_TEST_ASSERT(cx_linked_list_find(list, loc_next, loc_data, cx_cmp_int, &s, &i) == n);
+        CX_TEST_ASSERT(cx_linked_list_find(list, loc_next, loc_data, &s, &i, cx_cmp_int) == n);
         CX_TEST_ASSERT(i == 1);
         n = n->next;
         s = 6;
-        CX_TEST_ASSERT(cx_linked_list_find(list, loc_next, loc_data, cx_cmp_int, &s, &i) == n);
+        CX_TEST_ASSERT(cx_linked_list_find(list, loc_next, loc_data, &s, &i, cx_cmp_int) == n);
         CX_TEST_ASSERT(i == 2);
         n = n->next;
         s = 8;
-        CX_TEST_ASSERT(cx_linked_list_find(list, loc_next, loc_data, cx_cmp_int, &s, &i) == n);
+        CX_TEST_ASSERT(cx_linked_list_find(list, loc_next, loc_data, &s, &i, cx_cmp_int) == n);
         CX_TEST_ASSERT(i == 3);
         s = 10;
-        CX_TEST_ASSERT(cx_linked_list_find(list, loc_next, loc_data, cx_cmp_int, &s, &i) == NULL);
+        CX_TEST_ASSERT(cx_linked_list_find(list, loc_next, loc_data, &s, &i, cx_cmp_int) == NULL);
         s = -2;
-        CX_TEST_ASSERT(cx_linked_list_find(list, loc_next, loc_data, cx_cmp_int, &s, &i) == NULL);
+        CX_TEST_ASSERT(cx_linked_list_find(list, loc_next, loc_data, &s, &i, cx_cmp_int) == NULL);
     }
     destroy_nodes_test_data(list);
 }
@@ -1288,7 +1288,8 @@
         CX_TEST_ASSERT(list->collection.destructor_data == NULL);
         CX_TEST_ASSERT(cxListSize(list) == 0);
         CX_TEST_ASSERT(list->collection.allocator == alloc);
-        CX_TEST_ASSERT(list->collection.cmpfunc == cx_cmp_int);
+        CX_TEST_ASSERT(list->collection.simple_cmp == cx_cmp_int);
+        CX_TEST_ASSERT(list->collection.advanced_cmp == NULL);
         CX_TEST_ASSERT(!list->collection.store_pointer);
         cxListFree(list);
         CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc));
@@ -1306,7 +1307,9 @@
         CX_TEST_ASSERT(list->collection.destructor_data == NULL);
         CX_TEST_ASSERT(cxListSize(list) == 0);
         CX_TEST_ASSERT(list->collection.allocator == cxDefaultAllocator);
-        CX_TEST_ASSERT(list->collection.cmpfunc == NULL);
+        CX_TEST_ASSERT(list->collection.simple_cmp == NULL);
+        CX_TEST_ASSERT(list->collection.advanced_cmp == cx_acmp_memcmp);
+        CX_TEST_ASSERT(list->collection.cmp_data == &list->collection.elem_size);
         CX_TEST_ASSERT(!list->collection.store_pointer);
     }
     cxListFree(list);
@@ -1322,7 +1325,8 @@
         CX_TEST_ASSERT(list->collection.destructor_data == NULL);
         CX_TEST_ASSERT(cxListSize(list) == 0);
         CX_TEST_ASSERT(list->collection.allocator == cxDefaultAllocator);
-        CX_TEST_ASSERT(list->collection.cmpfunc == cx_cmp_ptr);
+        CX_TEST_ASSERT(list->collection.simple_cmp == cx_cmp_ptr);
+        CX_TEST_ASSERT(list->collection.advanced_cmp == NULL);
         CX_TEST_ASSERT(list->collection.store_pointer);
     }
     cxListFree(list);
@@ -1342,7 +1346,8 @@
         CX_TEST_ASSERT(list->collection.destructor_data == NULL);
         CX_TEST_ASSERT(cxListSize(list) == 0);
         CX_TEST_ASSERT(list->collection.allocator == alloc);
-        CX_TEST_ASSERT(list->collection.cmpfunc == cx_cmp_int);
+        CX_TEST_ASSERT(list->collection.simple_cmp == cx_cmp_int);
+        CX_TEST_ASSERT(list->collection.advanced_cmp == NULL);
         CX_TEST_ASSERT(!list->collection.store_pointer);
         cxListFree(list);
         CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc));
@@ -1360,7 +1365,9 @@
         CX_TEST_ASSERT(list->collection.destructor_data == NULL);
         CX_TEST_ASSERT(cxListSize(list) == 0);
         CX_TEST_ASSERT(list->collection.allocator == cxDefaultAllocator);
-        CX_TEST_ASSERT(list->collection.cmpfunc == NULL);
+        CX_TEST_ASSERT(list->collection.simple_cmp == NULL);
+        CX_TEST_ASSERT(list->collection.advanced_cmp == cx_acmp_memcmp);
+        CX_TEST_ASSERT(list->collection.cmp_data == &list->collection.elem_size);
         CX_TEST_ASSERT(!list->collection.store_pointer);
     }
     cxListFree(list);
@@ -1376,7 +1383,8 @@
         CX_TEST_ASSERT(list->collection.destructor_data == NULL);
         CX_TEST_ASSERT(cxListSize(list) == 0);
         CX_TEST_ASSERT(list->collection.allocator == cxDefaultAllocator);
-        CX_TEST_ASSERT(list->collection.cmpfunc == cx_cmp_ptr);
+        CX_TEST_ASSERT(list->collection.simple_cmp == cx_cmp_ptr);
+        CX_TEST_ASSERT(list->collection.advanced_cmp == NULL);
         CX_TEST_ASSERT(list->collection.store_pointer);
     }
     cxListFree(list);
@@ -1543,19 +1551,14 @@
 roll_out_test_invokers(name)
 
 static void set_default_class_funcs(CxList *list, cx_list_class *defaulted_cl) {
-    const cx_list_class *cl = list->climpl == NULL ? list->cl : list->climpl;
-    memcpy(defaulted_cl, cl, sizeof(cx_list_class));
+    memcpy(defaulted_cl, list->cl, sizeof(cx_list_class));
     defaulted_cl->insert_array = cx_list_default_insert_array;
     defaulted_cl->insert_unique = cx_list_default_insert_unique;
     defaulted_cl->insert_sorted = cx_list_default_insert_sorted;
     defaulted_cl->sort = cx_list_default_sort;
     defaulted_cl->swap = cx_list_default_swap;
     defaulted_cl->compare = NULL;
-    if (list->climpl == NULL) {
-        list->cl = defaulted_cl;
-    } else {
-        list->climpl = defaulted_cl;
-    }
+    list->cl = defaulted_cl;
 }
 
 #define do_set_default_class_funcs(list) \

mercurial