diff -r 74c6582adabb -r f74e4fc496a2 tests/test_list.c --- a/tests/test_list.c Fri Dec 19 14:14:22 2025 +0100 +++ b/tests/test_list.c Fri Dec 19 14:15:54 2025 +0100 @@ -539,6 +539,13 @@ } } +static int test_ccmp_int(const void *l, const void *r, void *c) { + int *z = c; + // return bullshit to make the test fail when c was not passed correctly + if (z == NULL || *z != 1337) return -1; + return cx_cmp_int(l, r); +} + typedef struct node { struct node *next; struct node *prev; @@ -1468,7 +1475,7 @@ CX_TEST_ASSERT(cxListSize(list) == 0); CX_TEST_ASSERT(list->collection.allocator == cxDefaultAllocator); CX_TEST_ASSERT(list->collection.simple_cmp == NULL); - CX_TEST_ASSERT(list->collection.advanced_cmp == cx_acmp_memcmp); + CX_TEST_ASSERT(list->collection.advanced_cmp == cx_ccmp_memcmp); CX_TEST_ASSERT(list->collection.cmp_data == &list->collection.elem_size); CX_TEST_ASSERT(!list->collection.store_pointer); } @@ -1526,7 +1533,7 @@ CX_TEST_ASSERT(cxListSize(list) == 0); CX_TEST_ASSERT(list->collection.allocator == cxDefaultAllocator); CX_TEST_ASSERT(list->collection.simple_cmp == NULL); - CX_TEST_ASSERT(list->collection.advanced_cmp == cx_acmp_memcmp); + CX_TEST_ASSERT(list->collection.advanced_cmp == cx_ccmp_memcmp); CX_TEST_ASSERT(list->collection.cmp_data == &list->collection.elem_size); CX_TEST_ASSERT(!list->collection.store_pointer); } @@ -2653,11 +2660,24 @@ const size_t len = 47; \ int *testdata = int_test_data_added_to_list(list, isptrlist, len); \ CxList *other = otherctr; \ + cxSetCompareFunc(list, cx_cmp_int); \ 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); \ free(testdata); \ +}) \ +roll_out_test_combos(compare2_##suffix, { \ + const size_t len = 47; \ + int *testdata = int_test_data_added_to_list(list, isptrlist, len); \ + CxList *other = otherctr; \ + int z = 1337; \ + cxSetAdvancedCompareFunc(list, test_ccmp_int, &z); \ + cxSetAdvancedCompareFunc(other, test_ccmp_int, &z); \ + for (size_t i = 0; i < len; i++) cxListAdd(other, &testdata[i]); \ + CX_TEST_CALL_SUBROUTINE(test_list_verify_compare, list, other); \ + cxListFree(other); \ + free(testdata); \ }) roll_out_compare_tests( @@ -3520,6 +3540,14 @@ cx_test_register(suite, test_list_parl_compare_arl); cx_test_register(suite, test_list_parl_compare_pll); cx_test_register(suite, test_list_parl_compare_parl); + cx_test_register(suite, test_list_arl_compare2_ll); + cx_test_register(suite, test_list_arl_compare2_arl); + cx_test_register(suite, test_list_arl_compare2_pll); + cx_test_register(suite, test_list_arl_compare2_parl); + cx_test_register(suite, test_list_parl_compare2_ll); + cx_test_register(suite, test_list_parl_compare2_arl); + cx_test_register(suite, test_list_parl_compare2_pll); + cx_test_register(suite, test_list_parl_compare2_parl); cx_test_register(suite, test_list_arl_simple_destr); cx_test_register(suite, test_list_parl_simple_destr); cx_test_register(suite, test_list_arl_advanced_destr); @@ -3657,6 +3685,14 @@ cx_test_register(suite, test_list_pll_compare_arl); cx_test_register(suite, test_list_pll_compare_pll); cx_test_register(suite, test_list_pll_compare_parl); + cx_test_register(suite, test_list_ll_compare2_ll); + cx_test_register(suite, test_list_ll_compare2_arl); + cx_test_register(suite, test_list_ll_compare2_pll); + cx_test_register(suite, test_list_ll_compare2_parl); + cx_test_register(suite, test_list_pll_compare2_ll); + cx_test_register(suite, test_list_pll_compare2_arl); + cx_test_register(suite, test_list_pll_compare2_pll); + cx_test_register(suite, test_list_pll_compare2_parl); cx_test_register(suite, test_list_ll_simple_destr); cx_test_register(suite, test_list_pll_simple_destr); cx_test_register(suite, test_list_ll_advanced_destr); @@ -3767,6 +3803,14 @@ cx_test_register(suite, test_list_pkvl_compare_arl); cx_test_register(suite, test_list_pkvl_compare_pll); cx_test_register(suite, test_list_pkvl_compare_parl); + cx_test_register(suite, test_list_kvl_compare2_ll); + cx_test_register(suite, test_list_kvl_compare2_arl); + cx_test_register(suite, test_list_kvl_compare2_pll); + cx_test_register(suite, test_list_kvl_compare2_parl); + cx_test_register(suite, test_list_pkvl_compare2_ll); + cx_test_register(suite, test_list_pkvl_compare2_arl); + cx_test_register(suite, test_list_pkvl_compare2_pll); + cx_test_register(suite, test_list_pkvl_compare2_parl); cx_test_register(suite, test_list_kvl_simple_destr); cx_test_register(suite, test_list_pkvl_simple_destr); cx_test_register(suite, test_list_kvl_advanced_destr);