1008 CX_TEST_ASSERT(list->collection.advanced_destructor == NULL); |
1008 CX_TEST_ASSERT(list->collection.advanced_destructor == NULL); |
1009 CX_TEST_ASSERT(list->collection.destructor_data == NULL); |
1009 CX_TEST_ASSERT(list->collection.destructor_data == NULL); |
1010 CX_TEST_ASSERT(cxListSize(list) == 0); |
1010 CX_TEST_ASSERT(cxListSize(list) == 0); |
1011 CX_TEST_ASSERT(list->collection.allocator == alloc); |
1011 CX_TEST_ASSERT(list->collection.allocator == alloc); |
1012 CX_TEST_ASSERT(list->collection.cmpfunc == cx_cmp_int); |
1012 CX_TEST_ASSERT(list->collection.cmpfunc == cx_cmp_int); |
1013 CX_TEST_ASSERT(!cxListIsStoringPointers(list)); |
1013 CX_TEST_ASSERT(!list->collection.store_pointer); |
1014 cxListFree(list); |
1014 cxListFree(list); |
1015 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
1015 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
1016 } |
1016 } |
1017 cx_testing_allocator_destroy(&talloc); |
1017 cx_testing_allocator_destroy(&talloc); |
1018 } |
1018 } |
1026 CX_TEST_ASSERT(list->collection.advanced_destructor == NULL); |
1026 CX_TEST_ASSERT(list->collection.advanced_destructor == NULL); |
1027 CX_TEST_ASSERT(list->collection.destructor_data == NULL); |
1027 CX_TEST_ASSERT(list->collection.destructor_data == NULL); |
1028 CX_TEST_ASSERT(cxListSize(list) == 0); |
1028 CX_TEST_ASSERT(cxListSize(list) == 0); |
1029 CX_TEST_ASSERT(list->collection.allocator == cxDefaultAllocator); |
1029 CX_TEST_ASSERT(list->collection.allocator == cxDefaultAllocator); |
1030 CX_TEST_ASSERT(list->collection.cmpfunc == NULL); |
1030 CX_TEST_ASSERT(list->collection.cmpfunc == NULL); |
1031 CX_TEST_ASSERT(!cxListIsStoringPointers(list)); |
1031 CX_TEST_ASSERT(!list->collection.store_pointer); |
1032 } |
|
1033 cxListFree(list); |
|
1034 } |
|
1035 |
|
1036 CX_TEST(test_list_ll_store_pointers) { |
|
1037 CxList *list = cxLinkedListCreateSimple(47); |
|
1038 CX_TEST_DO { |
|
1039 CX_TEST_ASSERT(!cxListIsStoringPointers(list)); |
|
1040 cxListStorePointers(list); |
|
1041 CX_TEST_ASSERT(list->collection.elem_size == sizeof(void *)); |
|
1042 CX_TEST_ASSERT(list->cl != NULL); |
|
1043 CX_TEST_ASSERT(list->climpl != NULL); |
|
1044 CX_TEST_ASSERT(cxListIsStoringPointers(list)); |
|
1045 cxListStoreObjects(list); |
|
1046 CX_TEST_ASSERT(list->cl != NULL); |
|
1047 CX_TEST_ASSERT(list->climpl == NULL); |
|
1048 CX_TEST_ASSERT(!cxListIsStoringPointers(list)); |
|
1049 } |
1032 } |
1050 cxListFree(list); |
1033 cxListFree(list); |
1051 } |
1034 } |
1052 |
1035 |
1053 CX_TEST(test_list_ll_create_simple_for_pointers) { |
1036 CX_TEST(test_list_ll_create_simple_for_pointers) { |
1059 CX_TEST_ASSERT(list->collection.advanced_destructor == NULL); |
1042 CX_TEST_ASSERT(list->collection.advanced_destructor == NULL); |
1060 CX_TEST_ASSERT(list->collection.destructor_data == NULL); |
1043 CX_TEST_ASSERT(list->collection.destructor_data == NULL); |
1061 CX_TEST_ASSERT(cxListSize(list) == 0); |
1044 CX_TEST_ASSERT(cxListSize(list) == 0); |
1062 CX_TEST_ASSERT(list->collection.allocator == cxDefaultAllocator); |
1045 CX_TEST_ASSERT(list->collection.allocator == cxDefaultAllocator); |
1063 CX_TEST_ASSERT(list->collection.cmpfunc == cx_cmp_ptr); |
1046 CX_TEST_ASSERT(list->collection.cmpfunc == cx_cmp_ptr); |
1064 CX_TEST_ASSERT(cxListIsStoringPointers(list)); |
1047 CX_TEST_ASSERT(list->collection.store_pointer); |
1065 } |
1048 } |
1066 cxListFree(list); |
1049 cxListFree(list); |
1067 } |
1050 } |
1068 |
1051 |
1069 CX_TEST(test_list_arl_create) { |
1052 CX_TEST(test_list_arl_create) { |
1078 CX_TEST_ASSERT(list->collection.advanced_destructor == NULL); |
1061 CX_TEST_ASSERT(list->collection.advanced_destructor == NULL); |
1079 CX_TEST_ASSERT(list->collection.destructor_data == NULL); |
1062 CX_TEST_ASSERT(list->collection.destructor_data == NULL); |
1080 CX_TEST_ASSERT(cxListSize(list) == 0); |
1063 CX_TEST_ASSERT(cxListSize(list) == 0); |
1081 CX_TEST_ASSERT(list->collection.allocator == alloc); |
1064 CX_TEST_ASSERT(list->collection.allocator == alloc); |
1082 CX_TEST_ASSERT(list->collection.cmpfunc == cx_cmp_int); |
1065 CX_TEST_ASSERT(list->collection.cmpfunc == cx_cmp_int); |
1083 CX_TEST_ASSERT(!cxListIsStoringPointers(list)); |
1066 CX_TEST_ASSERT(!list->collection.store_pointer); |
1084 cxListFree(list); |
1067 cxListFree(list); |
1085 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
1068 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
1086 } |
1069 } |
1087 cx_testing_allocator_destroy(&talloc); |
1070 cx_testing_allocator_destroy(&talloc); |
1088 } |
1071 } |
1096 CX_TEST_ASSERT(list->collection.advanced_destructor == NULL); |
1079 CX_TEST_ASSERT(list->collection.advanced_destructor == NULL); |
1097 CX_TEST_ASSERT(list->collection.destructor_data == NULL); |
1080 CX_TEST_ASSERT(list->collection.destructor_data == NULL); |
1098 CX_TEST_ASSERT(cxListSize(list) == 0); |
1081 CX_TEST_ASSERT(cxListSize(list) == 0); |
1099 CX_TEST_ASSERT(list->collection.allocator == cxDefaultAllocator); |
1082 CX_TEST_ASSERT(list->collection.allocator == cxDefaultAllocator); |
1100 CX_TEST_ASSERT(list->collection.cmpfunc == NULL); |
1083 CX_TEST_ASSERT(list->collection.cmpfunc == NULL); |
1101 CX_TEST_ASSERT(!cxListIsStoringPointers(list)); |
1084 CX_TEST_ASSERT(!list->collection.store_pointer); |
1102 } |
1085 } |
1103 cxListFree(list); |
1086 cxListFree(list); |
1104 } |
1087 } |
1105 |
1088 |
1106 CX_TEST(test_list_arl_create_simple_for_pointers) { |
1089 CX_TEST(test_list_arl_create_simple_for_pointers) { |
1112 CX_TEST_ASSERT(list->collection.advanced_destructor == NULL); |
1095 CX_TEST_ASSERT(list->collection.advanced_destructor == NULL); |
1113 CX_TEST_ASSERT(list->collection.destructor_data == NULL); |
1096 CX_TEST_ASSERT(list->collection.destructor_data == NULL); |
1114 CX_TEST_ASSERT(cxListSize(list) == 0); |
1097 CX_TEST_ASSERT(cxListSize(list) == 0); |
1115 CX_TEST_ASSERT(list->collection.allocator == cxDefaultAllocator); |
1098 CX_TEST_ASSERT(list->collection.allocator == cxDefaultAllocator); |
1116 CX_TEST_ASSERT(list->collection.cmpfunc == cx_cmp_ptr); |
1099 CX_TEST_ASSERT(list->collection.cmpfunc == cx_cmp_ptr); |
1117 CX_TEST_ASSERT(cxListIsStoringPointers(list)); |
1100 CX_TEST_ASSERT(list->collection.store_pointer); |
1118 } |
1101 } |
1119 cxListFree(list); |
1102 cxListFree(list); |
1120 } |
1103 } |
1121 |
1104 |
1122 static void test_fake_simple_int_destr(void *elem) { |
1105 static void test_fake_simple_int_destr(void *elem) { |
1860 |
1843 |
1861 static CX_TEST_SUBROUTINE(test_list_verify_destructor, CxList *list, |
1844 static CX_TEST_SUBROUTINE(test_list_verify_destructor, CxList *list, |
1862 const int *testdata, size_t testdata_len) { |
1845 const int *testdata, size_t testdata_len) { |
1863 destr_test_ctr = 0; |
1846 destr_test_ctr = 0; |
1864 |
1847 |
1865 int off = cxListIsStoringPointers(list) ? 1 : 0; |
1848 int off = list->collection.store_pointer ? 1 : 0; |
1866 |
1849 |
1867 cxListRemove(list, 15); |
1850 cxListRemove(list, 15); |
1868 CX_TEST_ASSERT(1 == destr_test_ctr); |
1851 CX_TEST_ASSERT(1 == destr_test_ctr); |
1869 CX_TEST_ASSERT(testdata[15] == destr_last_value + off); |
1852 CX_TEST_ASSERT(testdata[15] == destr_last_value + off); |
1870 CX_TEST_ASSERT(testdata_len - destr_test_ctr == cxListSize(list)); |
1853 CX_TEST_ASSERT(testdata_len - destr_test_ctr == cxListSize(list)); |
2023 cx_test_register(suite, test_linked_list_sort); |
2006 cx_test_register(suite, test_linked_list_sort); |
2024 cx_test_register(suite, test_linked_list_reverse); |
2007 cx_test_register(suite, test_linked_list_reverse); |
2025 |
2008 |
2026 cx_test_register(suite, test_list_ll_create); |
2009 cx_test_register(suite, test_list_ll_create); |
2027 cx_test_register(suite, test_list_ll_create_simple); |
2010 cx_test_register(suite, test_list_ll_create_simple); |
2028 cx_test_register(suite, test_list_ll_store_pointers); |
|
2029 cx_test_register(suite, test_list_ll_create_simple_for_pointers); |
2011 cx_test_register(suite, test_list_ll_create_simple_for_pointers); |
2030 cx_test_register(suite, test_list_pll_destroy_no_destr); |
2012 cx_test_register(suite, test_list_pll_destroy_no_destr); |
2031 cx_test_register(suite, test_list_pll_destroy_simple_destr); |
2013 cx_test_register(suite, test_list_pll_destroy_simple_destr); |
2032 cx_test_register(suite, test_list_pll_destroy_adv_destr); |
2014 cx_test_register(suite, test_list_pll_destroy_adv_destr); |
2033 |
2015 |