| 2752 cxListFree(dst); |
2752 cxListFree(dst); |
| 2753 cxListFree(minuend); |
2753 cxListFree(minuend); |
| 2754 cxListFree(subtrahend); |
2754 cxListFree(subtrahend); |
| 2755 cxListFree(expected); |
2755 cxListFree(expected); |
| 2756 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
2756 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
| |
2757 cx_testing_allocator_destroy(&talloc); |
| 2757 } |
2758 } |
| 2758 |
2759 |
| 2759 CX_TEST(test_list_difference_unsorted) { |
2760 CX_TEST(test_list_difference_unsorted) { |
| 2760 CX_TEST_DO { |
2761 CX_TEST_DO { |
| 2761 CX_TEST_CALL_SUBROUTINE(verify_difference, false, false); |
2762 CX_TEST_CALL_SUBROUTINE(verify_difference, false, false); |
| 2844 cxListFree(dst); |
2845 cxListFree(dst); |
| 2845 cxListFree(src); |
2846 cxListFree(src); |
| 2846 cxListFree(other); |
2847 cxListFree(other); |
| 2847 cxListFree(expected); |
2848 cxListFree(expected); |
| 2848 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
2849 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
| |
2850 cx_testing_allocator_destroy(&talloc); |
| 2849 } |
2851 } |
| 2850 |
2852 |
| 2851 CX_TEST(test_list_intersection_unsorted) { |
2853 CX_TEST(test_list_intersection_unsorted) { |
| 2852 CX_TEST_DO { |
2854 CX_TEST_DO { |
| 2853 CX_TEST_CALL_SUBROUTINE(verify_intersection, false, false); |
2855 CX_TEST_CALL_SUBROUTINE(verify_intersection, false, false); |
| 2948 cxListFree(dst); |
2950 cxListFree(dst); |
| 2949 cxListFree(src); |
2951 cxListFree(src); |
| 2950 cxListFree(other); |
2952 cxListFree(other); |
| 2951 cxListFree(expected); |
2953 cxListFree(expected); |
| 2952 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
2954 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
| |
2955 cx_testing_allocator_destroy(&talloc); |
| 2953 } |
2956 } |
| 2954 |
2957 |
| 2955 CX_TEST(test_list_union_unsorted) { |
2958 CX_TEST(test_list_union_unsorted) { |
| 2956 CX_TEST_DO { |
2959 CX_TEST_DO { |
| 2957 CX_TEST_CALL_SUBROUTINE(verify_union, false, false); |
2960 CX_TEST_CALL_SUBROUTINE(verify_union, false, false); |
| 2994 cxListInsertSortedArray(lc, c, cx_nmemb(c)); |
2997 cxListInsertSortedArray(lc, c, cx_nmemb(c)); |
| 2995 CxList *ld = cxArrayListCreateSimple(sizeof(int), 8); |
2998 CxList *ld = cxArrayListCreateSimple(sizeof(int), 8); |
| 2996 cxCollectionCompareFunc(ld, cx_cmp_int); |
2999 cxCollectionCompareFunc(ld, cx_cmp_int); |
| 2997 cxListInsertSortedArray(ld, d, cx_nmemb(d)); |
3000 cxListInsertSortedArray(ld, d, cx_nmemb(d)); |
| 2998 |
3001 |
| 2999 CxList *d1 = cxArrayListCreateSimple(CX_STORE_POINTERS, 8); |
3002 CxList *d1 = cxArrayListCreateSimple(sizeof(int), 8); |
| 3000 cxCollectionCompareFunc(d1, cx_cmp_int); |
3003 cxCollectionCompareFunc(d1, cx_cmp_int); |
| 3001 cxDefineAdvancedDestructor(d1, cxFree, (void*) cxDefaultAllocator); |
3004 CxList *d2 = cxArrayListCreateSimple(sizeof(int), 8); |
| 3002 CxList *d2 = cxArrayListCreateSimple(CX_STORE_POINTERS, 8); |
|
| 3003 cxCollectionCompareFunc(d2, cx_cmp_int); |
3005 cxCollectionCompareFunc(d2, cx_cmp_int); |
| 3004 cxDefineAdvancedDestructor(d2, cxFree, (void*) cxDefaultAllocator); |
|
| 3005 |
3006 |
| 3006 CX_TEST_DO { |
3007 CX_TEST_DO { |
| 3007 // clone a into d1 |
3008 // clone a into d1 |
| 3008 CX_TEST_ASSERT(0 == cxListCloneSimple(d1, la)); |
3009 CX_TEST_ASSERT(0 == cxListCloneSimple(d1, la)); |
| 3009 CX_TEST_ASSERT(0 == cxListCompare(d1, la)); |
3010 CX_TEST_ASSERT(0 == cxListCompare(d1, la)); |
| 3013 CX_TEST_ASSERT(0 == cxListUnionSimple(d2, d1, lb)); |
3014 CX_TEST_ASSERT(0 == cxListUnionSimple(d2, d1, lb)); |
| 3014 CX_TEST_ASSERT(cxCollectionSorted(d2)); |
3015 CX_TEST_ASSERT(cxCollectionSorted(d2)); |
| 3015 CxList *expected_union = cxArrayListCreateSimple(sizeof(int), 8); |
3016 CxList *expected_union = cxArrayListCreateSimple(sizeof(int), 8); |
| 3016 { |
3017 { |
| 3017 int expected[] = {1, 2, 3, 5, 7, 8, 9, 10, 11}; |
3018 int expected[] = {1, 2, 3, 5, 7, 8, 9, 10, 11}; |
| 3018 cxListInsertSortedArray(expected_union, expected, cx_nmemb(expected)); |
3019 cxListAddArray(expected_union, expected, cx_nmemb(expected)); |
| 3019 } |
3020 } |
| 3020 CX_TEST_ASSERT(0 == cxListCompare(d2, expected_union)); |
3021 CX_TEST_ASSERT(0 == cxListCompare(d2, expected_union)); |
| 3021 cxListFree(expected_union); |
3022 cxListFree(expected_union); |
| 3022 |
3023 |
| 3023 // intersection of (a union b) and c |
3024 // intersection of (a union b) and c |
| 3025 CX_TEST_ASSERT(0 == cxListIntersectionSimple(d1, d2, lc)); |
3026 CX_TEST_ASSERT(0 == cxListIntersectionSimple(d1, d2, lc)); |
| 3026 CX_TEST_ASSERT(cxCollectionSorted(d1)); |
3027 CX_TEST_ASSERT(cxCollectionSorted(d1)); |
| 3027 CxList *expected_intersection = cxArrayListCreateSimple(sizeof(int), 8); |
3028 CxList *expected_intersection = cxArrayListCreateSimple(sizeof(int), 8); |
| 3028 { |
3029 { |
| 3029 int expected[] = {2, 8, 10}; |
3030 int expected[] = {2, 8, 10}; |
| 3030 cxListInsertSortedArray(expected_intersection, expected, cx_nmemb(expected)); |
3031 cxListAddArray(expected_intersection, expected, cx_nmemb(expected)); |
| 3031 } |
3032 } |
| 3032 CX_TEST_ASSERT(0 == cxListCompare(d1, expected_intersection)); |
3033 CX_TEST_ASSERT(0 == cxListCompare(d1, expected_intersection)); |
| 3033 cxListFree(expected_intersection); |
3034 cxListFree(expected_intersection); |
| 3034 |
3035 |
| 3035 // difference of ((a union b) intersect c) minus d |
3036 // difference of ((a union b) intersect c) minus d |
| 3037 CX_TEST_ASSERT(0 == cxListDifferenceSimple(d2, d1, ld)); |
3038 CX_TEST_ASSERT(0 == cxListDifferenceSimple(d2, d1, ld)); |
| 3038 CX_TEST_ASSERT(cxCollectionSorted(d2)); |
3039 CX_TEST_ASSERT(cxCollectionSorted(d2)); |
| 3039 CxList *expected_difference = cxArrayListCreateSimple(sizeof(int), 8); |
3040 CxList *expected_difference = cxArrayListCreateSimple(sizeof(int), 8); |
| 3040 { |
3041 { |
| 3041 int expected[] = {2, 10}; |
3042 int expected[] = {2, 10}; |
| 3042 cxListInsertSortedArray(expected_difference, expected, cx_nmemb(expected)); |
3043 cxListAddArray(expected_difference, expected, cx_nmemb(expected)); |
| 3043 } |
3044 } |
| 3044 CX_TEST_ASSERT(0 == cxListCompare(d2, expected_difference)); |
3045 CX_TEST_ASSERT(0 == cxListCompare(d2, expected_difference)); |
| 3045 cxListFree(expected_difference); |
3046 cxListFree(expected_difference); |
| 3046 } |
3047 } |
| 3047 |
3048 |