diff -r 943bfd9e7978 -r 0ac4aa1737fd tests/test_list.c --- a/tests/test_list.c Fri Oct 17 14:14:21 2025 +0200 +++ b/tests/test_list.c Fri Oct 17 15:04:56 2025 +0200 @@ -1814,6 +1814,67 @@ } }) +roll_out_test_combos_with_defaulted_funcs(insert_unique_not_sorted, { + int d1 = 50; + int d2 = 80; + int d3 = 60; + int d4 = 40; + int d5 = 70; + int d6a[6] = array_init(52, 54, 56, 62, 64, 75); + int d7a[6] = array_init(51, 57, 58, 65, 77, 78); + int d8 = 90; + int d9 = 56; + int d10a[3] = array_init(67, 75, 90); + int *d6ptr[6]; + int *d7ptr[6]; + int *d10ptr[3]; + for (size_t i = 0; i < 6; i++) { + d6ptr[i] = &d6a[i]; + d7ptr[i] = &d7a[i]; + } + for (size_t i = 0 ; i < 3 ; i++) { + d10ptr[i] = &d10a[i]; + } + size_t inserted; + int expected[19] = array_init( + 50, 80, 60, 40, 70, 52, 54, 56, 62, 64, + 75, 51, 57, 58, 65, 77, 78, 90, 67 + ); + + // begin with an unsorted list! + CX_TEST_ASSERT(0 == cxListAdd(list, &d1)); + CX_TEST_ASSERT(0 == cxListAdd(list, &d2)); + CX_TEST_ASSERT(0 == cxListAdd(list, &d3)); + CX_TEST_ASSERT(0 == cxListAdd(list, &d4)); + + // not start adding unique items + CX_TEST_ASSERT(0 == cxListInsertUnique(list, &d5)); + if (isptrlist) { + inserted = cxListInsertUniqueArray(list, d6ptr, 6); + } else { + inserted = cxListInsertUniqueArray(list, d6a, 6); + } + CX_TEST_ASSERT(inserted == 6); + if (isptrlist) { + inserted = cxListInsertUniqueArray(list, d7ptr, 6); + } else { + inserted = cxListInsertUniqueArray(list, d7a, 6); + } + CX_TEST_ASSERT(inserted == 6); + CX_TEST_ASSERT(0 == cxListInsertUnique(list, &d8)); + CX_TEST_ASSERT(0 == cxListInsertUnique(list, &d9)); + if (isptrlist) { + inserted = cxListInsertUniqueArray(list, d10ptr, 3); + } else { + inserted = cxListInsertUniqueArray(list, d10a, 3); + } + CX_TEST_ASSERT(inserted == 3); + CX_TEST_ASSERT(cxListSize(list) == 19); + for (size_t i = 0; i < 19; i++) { + CX_TEST_ASSERT(*(int *) cxListAt(list, i) == expected[i]); + } +}) + roll_out_test_combos(remove, { const size_t testdata_len = 32; int *testdata = int_test_data_added_to_list(list, isptrlist, testdata_len); @@ -2554,6 +2615,8 @@ cx_test_register(suite, test_list_parl_insert_sorted); cx_test_register(suite, test_list_arl_insert_unique); cx_test_register(suite, test_list_parl_insert_unique); + cx_test_register(suite, test_list_arl_insert_unique_not_sorted); + cx_test_register(suite, test_list_parl_insert_unique_not_sorted); cx_test_register(suite, test_list_arl_remove); cx_test_register(suite, test_list_parl_remove); cx_test_register(suite, test_list_arl_remove_and_get); @@ -2611,6 +2674,8 @@ cx_test_register(suite, test_list_parlm_insert_sorted); cx_test_register(suite, test_list_arlm_insert_unique); cx_test_register(suite, test_list_parlm_insert_unique); + cx_test_register(suite, test_list_arlm_insert_unique_not_sorted); + cx_test_register(suite, test_list_parlm_insert_unique_not_sorted); cx_test_register(suite, test_list_arlm_swap); cx_test_register(suite, test_list_parlm_swap); cx_test_register(suite, test_list_arlm_sort); @@ -2666,6 +2731,8 @@ cx_test_register(suite, test_list_pll_insert_sorted); cx_test_register(suite, test_list_ll_insert_unique); cx_test_register(suite, test_list_pll_insert_unique); + cx_test_register(suite, test_list_ll_insert_unique_not_sorted); + cx_test_register(suite, test_list_pll_insert_unique_not_sorted); cx_test_register(suite, test_list_ll_remove); cx_test_register(suite, test_list_pll_remove); cx_test_register(suite, test_list_ll_remove_and_get); @@ -2722,6 +2789,8 @@ cx_test_register(suite, test_list_pllm_insert_sorted); cx_test_register(suite, test_list_llm_insert_unique); cx_test_register(suite, test_list_pllm_insert_unique); + cx_test_register(suite, test_list_llm_insert_unique_not_sorted); + cx_test_register(suite, test_list_pllm_insert_unique_not_sorted); cx_test_register(suite, test_list_llm_swap); cx_test_register(suite, test_list_pllm_swap); cx_test_register(suite, test_list_llm_sort); @@ -2750,6 +2819,8 @@ cx_test_register(suite, test_list_pkvl_insert_sorted); cx_test_register(suite, test_list_kvl_insert_unique); cx_test_register(suite, test_list_pkvl_insert_unique); + cx_test_register(suite, test_list_kvl_insert_unique_not_sorted); + cx_test_register(suite, test_list_pkvl_insert_unique_not_sorted); cx_test_register(suite, test_list_kvl_remove); cx_test_register(suite, test_list_pkvl_remove); cx_test_register(suite, test_list_kvl_remove_and_get);