| 537 s = 70; // exact match, we want the smallest index |
537 s = 70; // exact match, we want the smallest index |
| 538 CX_TEST_ASSERT(12 == cx_array_binary_search_sup(array, 18, sizeof(int), &s, cx_cmp_int)); |
538 CX_TEST_ASSERT(12 == cx_array_binary_search_sup(array, 18, sizeof(int), &s, cx_cmp_int)); |
| 539 } |
539 } |
| 540 } |
540 } |
| 541 |
541 |
| |
542 static int test_ccmp_int(const void *l, const void *r, void *c) { |
| |
543 int *z = c; |
| |
544 // return bullshit to make the test fail when c was not passed correctly |
| |
545 if (z == NULL || *z != 1337) return -1; |
| |
546 return cx_cmp_int(l, r); |
| |
547 } |
| |
548 |
| 542 typedef struct node { |
549 typedef struct node { |
| 543 struct node *next; |
550 struct node *next; |
| 544 struct node *prev; |
551 struct node *prev; |
| 545 int data; |
552 int data; |
| 546 } node; |
553 } node; |
| 1466 CX_TEST_ASSERT(list->collection.advanced_destructor == NULL); |
1473 CX_TEST_ASSERT(list->collection.advanced_destructor == NULL); |
| 1467 CX_TEST_ASSERT(list->collection.destructor_data == NULL); |
1474 CX_TEST_ASSERT(list->collection.destructor_data == NULL); |
| 1468 CX_TEST_ASSERT(cxListSize(list) == 0); |
1475 CX_TEST_ASSERT(cxListSize(list) == 0); |
| 1469 CX_TEST_ASSERT(list->collection.allocator == cxDefaultAllocator); |
1476 CX_TEST_ASSERT(list->collection.allocator == cxDefaultAllocator); |
| 1470 CX_TEST_ASSERT(list->collection.simple_cmp == NULL); |
1477 CX_TEST_ASSERT(list->collection.simple_cmp == NULL); |
| 1471 CX_TEST_ASSERT(list->collection.advanced_cmp == cx_acmp_memcmp); |
1478 CX_TEST_ASSERT(list->collection.advanced_cmp == cx_ccmp_memcmp); |
| 1472 CX_TEST_ASSERT(list->collection.cmp_data == &list->collection.elem_size); |
1479 CX_TEST_ASSERT(list->collection.cmp_data == &list->collection.elem_size); |
| 1473 CX_TEST_ASSERT(!list->collection.store_pointer); |
1480 CX_TEST_ASSERT(!list->collection.store_pointer); |
| 1474 } |
1481 } |
| 1475 cxListFree(list); |
1482 cxListFree(list); |
| 1476 } |
1483 } |
| 1524 CX_TEST_ASSERT(list->collection.advanced_destructor == NULL); |
1531 CX_TEST_ASSERT(list->collection.advanced_destructor == NULL); |
| 1525 CX_TEST_ASSERT(list->collection.destructor_data == NULL); |
1532 CX_TEST_ASSERT(list->collection.destructor_data == NULL); |
| 1526 CX_TEST_ASSERT(cxListSize(list) == 0); |
1533 CX_TEST_ASSERT(cxListSize(list) == 0); |
| 1527 CX_TEST_ASSERT(list->collection.allocator == cxDefaultAllocator); |
1534 CX_TEST_ASSERT(list->collection.allocator == cxDefaultAllocator); |
| 1528 CX_TEST_ASSERT(list->collection.simple_cmp == NULL); |
1535 CX_TEST_ASSERT(list->collection.simple_cmp == NULL); |
| 1529 CX_TEST_ASSERT(list->collection.advanced_cmp == cx_acmp_memcmp); |
1536 CX_TEST_ASSERT(list->collection.advanced_cmp == cx_ccmp_memcmp); |
| 1530 CX_TEST_ASSERT(list->collection.cmp_data == &list->collection.elem_size); |
1537 CX_TEST_ASSERT(list->collection.cmp_data == &list->collection.elem_size); |
| 1531 CX_TEST_ASSERT(!list->collection.store_pointer); |
1538 CX_TEST_ASSERT(!list->collection.store_pointer); |
| 1532 } |
1539 } |
| 1533 cxListFree(list); |
1540 cxListFree(list); |
| 1534 } |
1541 } |
| 2651 #define roll_out_compare_tests(suffix, otherctr) \ |
2658 #define roll_out_compare_tests(suffix, otherctr) \ |
| 2652 roll_out_test_combos(compare_##suffix, { \ |
2659 roll_out_test_combos(compare_##suffix, { \ |
| 2653 const size_t len = 47; \ |
2660 const size_t len = 47; \ |
| 2654 int *testdata = int_test_data_added_to_list(list, isptrlist, len); \ |
2661 int *testdata = int_test_data_added_to_list(list, isptrlist, len); \ |
| 2655 CxList *other = otherctr; \ |
2662 CxList *other = otherctr; \ |
| |
2663 cxSetCompareFunc(list, cx_cmp_int); \ |
| 2656 cxSetCompareFunc(other, cx_cmp_int); \ |
2664 cxSetCompareFunc(other, cx_cmp_int); \ |
| |
2665 for (size_t i = 0; i < len; i++) cxListAdd(other, &testdata[i]); \ |
| |
2666 CX_TEST_CALL_SUBROUTINE(test_list_verify_compare, list, other); \ |
| |
2667 cxListFree(other); \ |
| |
2668 free(testdata); \ |
| |
2669 }) \ |
| |
2670 roll_out_test_combos(compare2_##suffix, { \ |
| |
2671 const size_t len = 47; \ |
| |
2672 int *testdata = int_test_data_added_to_list(list, isptrlist, len); \ |
| |
2673 CxList *other = otherctr; \ |
| |
2674 int z = 1337; \ |
| |
2675 cxSetAdvancedCompareFunc(list, test_ccmp_int, &z); \ |
| |
2676 cxSetAdvancedCompareFunc(other, test_ccmp_int, &z); \ |
| 2657 for (size_t i = 0; i < len; i++) cxListAdd(other, &testdata[i]); \ |
2677 for (size_t i = 0; i < len; i++) cxListAdd(other, &testdata[i]); \ |
| 2658 CX_TEST_CALL_SUBROUTINE(test_list_verify_compare, list, other); \ |
2678 CX_TEST_CALL_SUBROUTINE(test_list_verify_compare, list, other); \ |
| 2659 cxListFree(other); \ |
2679 cxListFree(other); \ |
| 2660 free(testdata); \ |
2680 free(testdata); \ |
| 2661 }) |
2681 }) |
| 3518 cx_test_register(suite, test_list_arl_compare_parl); |
3538 cx_test_register(suite, test_list_arl_compare_parl); |
| 3519 cx_test_register(suite, test_list_parl_compare_ll); |
3539 cx_test_register(suite, test_list_parl_compare_ll); |
| 3520 cx_test_register(suite, test_list_parl_compare_arl); |
3540 cx_test_register(suite, test_list_parl_compare_arl); |
| 3521 cx_test_register(suite, test_list_parl_compare_pll); |
3541 cx_test_register(suite, test_list_parl_compare_pll); |
| 3522 cx_test_register(suite, test_list_parl_compare_parl); |
3542 cx_test_register(suite, test_list_parl_compare_parl); |
| |
3543 cx_test_register(suite, test_list_arl_compare2_ll); |
| |
3544 cx_test_register(suite, test_list_arl_compare2_arl); |
| |
3545 cx_test_register(suite, test_list_arl_compare2_pll); |
| |
3546 cx_test_register(suite, test_list_arl_compare2_parl); |
| |
3547 cx_test_register(suite, test_list_parl_compare2_ll); |
| |
3548 cx_test_register(suite, test_list_parl_compare2_arl); |
| |
3549 cx_test_register(suite, test_list_parl_compare2_pll); |
| |
3550 cx_test_register(suite, test_list_parl_compare2_parl); |
| 3523 cx_test_register(suite, test_list_arl_simple_destr); |
3551 cx_test_register(suite, test_list_arl_simple_destr); |
| 3524 cx_test_register(suite, test_list_parl_simple_destr); |
3552 cx_test_register(suite, test_list_parl_simple_destr); |
| 3525 cx_test_register(suite, test_list_arl_advanced_destr); |
3553 cx_test_register(suite, test_list_arl_advanced_destr); |
| 3526 cx_test_register(suite, test_list_parl_advanced_destr); |
3554 cx_test_register(suite, test_list_parl_advanced_destr); |
| 3527 cx_test_register(suite, test_list_arl_reserve_and_shrink); |
3555 cx_test_register(suite, test_list_arl_reserve_and_shrink); |
| 3655 cx_test_register(suite, test_list_ll_compare_parl); |
3683 cx_test_register(suite, test_list_ll_compare_parl); |
| 3656 cx_test_register(suite, test_list_pll_compare_ll); |
3684 cx_test_register(suite, test_list_pll_compare_ll); |
| 3657 cx_test_register(suite, test_list_pll_compare_arl); |
3685 cx_test_register(suite, test_list_pll_compare_arl); |
| 3658 cx_test_register(suite, test_list_pll_compare_pll); |
3686 cx_test_register(suite, test_list_pll_compare_pll); |
| 3659 cx_test_register(suite, test_list_pll_compare_parl); |
3687 cx_test_register(suite, test_list_pll_compare_parl); |
| |
3688 cx_test_register(suite, test_list_ll_compare2_ll); |
| |
3689 cx_test_register(suite, test_list_ll_compare2_arl); |
| |
3690 cx_test_register(suite, test_list_ll_compare2_pll); |
| |
3691 cx_test_register(suite, test_list_ll_compare2_parl); |
| |
3692 cx_test_register(suite, test_list_pll_compare2_ll); |
| |
3693 cx_test_register(suite, test_list_pll_compare2_arl); |
| |
3694 cx_test_register(suite, test_list_pll_compare2_pll); |
| |
3695 cx_test_register(suite, test_list_pll_compare2_parl); |
| 3660 cx_test_register(suite, test_list_ll_simple_destr); |
3696 cx_test_register(suite, test_list_ll_simple_destr); |
| 3661 cx_test_register(suite, test_list_pll_simple_destr); |
3697 cx_test_register(suite, test_list_pll_simple_destr); |
| 3662 cx_test_register(suite, test_list_ll_advanced_destr); |
3698 cx_test_register(suite, test_list_ll_advanced_destr); |
| 3663 cx_test_register(suite, test_list_pll_advanced_destr); |
3699 cx_test_register(suite, test_list_pll_advanced_destr); |
| 3664 cx_test_register(suite, test_list_ll_reserve_and_shrink); |
3700 cx_test_register(suite, test_list_ll_reserve_and_shrink); |
| 3765 cx_test_register(suite, test_list_kvl_compare_parl); |
3801 cx_test_register(suite, test_list_kvl_compare_parl); |
| 3766 cx_test_register(suite, test_list_pkvl_compare_ll); |
3802 cx_test_register(suite, test_list_pkvl_compare_ll); |
| 3767 cx_test_register(suite, test_list_pkvl_compare_arl); |
3803 cx_test_register(suite, test_list_pkvl_compare_arl); |
| 3768 cx_test_register(suite, test_list_pkvl_compare_pll); |
3804 cx_test_register(suite, test_list_pkvl_compare_pll); |
| 3769 cx_test_register(suite, test_list_pkvl_compare_parl); |
3805 cx_test_register(suite, test_list_pkvl_compare_parl); |
| |
3806 cx_test_register(suite, test_list_kvl_compare2_ll); |
| |
3807 cx_test_register(suite, test_list_kvl_compare2_arl); |
| |
3808 cx_test_register(suite, test_list_kvl_compare2_pll); |
| |
3809 cx_test_register(suite, test_list_kvl_compare2_parl); |
| |
3810 cx_test_register(suite, test_list_pkvl_compare2_ll); |
| |
3811 cx_test_register(suite, test_list_pkvl_compare2_arl); |
| |
3812 cx_test_register(suite, test_list_pkvl_compare2_pll); |
| |
3813 cx_test_register(suite, test_list_pkvl_compare2_parl); |
| 3770 cx_test_register(suite, test_list_kvl_simple_destr); |
3814 cx_test_register(suite, test_list_kvl_simple_destr); |
| 3771 cx_test_register(suite, test_list_pkvl_simple_destr); |
3815 cx_test_register(suite, test_list_pkvl_simple_destr); |
| 3772 cx_test_register(suite, test_list_kvl_advanced_destr); |
3816 cx_test_register(suite, test_list_kvl_advanced_destr); |
| 3773 cx_test_register(suite, test_list_pkvl_advanced_destr); |
3817 cx_test_register(suite, test_list_pkvl_advanced_destr); |
| 3774 cx_test_register(suite, test_list_kvl_reserve_and_shrink); |
3818 cx_test_register(suite, test_list_kvl_reserve_and_shrink); |