| 46 } |
46 } |
| 47 CX_TEST_ASSERT(map->collection.elem_size == 1); |
47 CX_TEST_ASSERT(map->collection.elem_size == 1); |
| 48 CX_TEST_ASSERT(map->collection.size == 0); |
48 CX_TEST_ASSERT(map->collection.size == 0); |
| 49 CX_TEST_ASSERT(map->collection.allocator == allocator); |
49 CX_TEST_ASSERT(map->collection.allocator == allocator); |
| 50 CX_TEST_ASSERT(!map->collection.store_pointer); |
50 CX_TEST_ASSERT(!map->collection.store_pointer); |
| 51 CX_TEST_ASSERT(map->collection.cmpfunc == NULL); |
51 CX_TEST_ASSERT(map->collection.simple_cmp == NULL); |
| |
52 CX_TEST_ASSERT(map->collection.advanced_cmp == cx_acmp_memcmp); |
| |
53 CX_TEST_ASSERT(map->collection.cmp_data == &map->collection.elem_size); |
| 52 CX_TEST_ASSERT(map->collection.simple_destructor == NULL); |
54 CX_TEST_ASSERT(map->collection.simple_destructor == NULL); |
| 53 CX_TEST_ASSERT(map->collection.advanced_destructor == NULL); |
55 CX_TEST_ASSERT(map->collection.advanced_destructor == NULL); |
| 54 CX_TEST_ASSERT(map->collection.destructor_data == NULL); |
56 CX_TEST_ASSERT(map->collection.destructor_data == NULL); |
| 55 |
57 |
| 56 cxMapFree(map); |
58 cxMapFree(map); |
| 72 } |
74 } |
| 73 CX_TEST_ASSERT(map->collection.size == 0); |
75 CX_TEST_ASSERT(map->collection.size == 0); |
| 74 CX_TEST_ASSERT(map->collection.allocator == allocator); |
76 CX_TEST_ASSERT(map->collection.allocator == allocator); |
| 75 CX_TEST_ASSERT(map->collection.store_pointer); |
77 CX_TEST_ASSERT(map->collection.store_pointer); |
| 76 CX_TEST_ASSERT(map->collection.elem_size == sizeof(void *)); |
78 CX_TEST_ASSERT(map->collection.elem_size == sizeof(void *)); |
| |
79 CX_TEST_ASSERT(map->collection.simple_cmp == cx_cmp_ptr); |
| |
80 CX_TEST_ASSERT(map->collection.advanced_cmp == NULL); |
| 77 |
81 |
| 78 cxMapFree(map); |
82 cxMapFree(map); |
| 79 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
83 CX_TEST_ASSERT(cx_testing_allocator_verify(&talloc)); |
| 80 } |
84 } |
| 81 cx_testing_allocator_destroy(&talloc); |
85 cx_testing_allocator_destroy(&talloc); |
| 1270 } |
1274 } |
| 1271 |
1275 |
| 1272 CX_TEST(test_hash_map_compare) { |
1276 CX_TEST(test_hash_map_compare) { |
| 1273 CxMap *map1 = cxHashMapCreate(NULL, sizeof(int), 0); |
1277 CxMap *map1 = cxHashMapCreate(NULL, sizeof(int), 0); |
| 1274 CxMap *map2 = cxHashMapCreate(NULL, CX_STORE_POINTERS, 0); |
1278 CxMap *map2 = cxHashMapCreate(NULL, CX_STORE_POINTERS, 0); |
| 1275 // TODO: fix specification of compare function once #622 is realized |
1279 cxSetCompareFunc(map1, cx_cmp_int); |
| 1276 map1->collection.cmpfunc = cx_cmp_int; |
1280 cxSetCompareFunc(map2, cx_cmp_int); |
| 1277 map2->collection.cmpfunc = cx_cmp_int; |
|
| 1278 |
1281 |
| 1279 // some ints we can point to in the pointer map |
1282 // some ints we can point to in the pointer map |
| 1280 int z13 = 13; |
1283 int z13 = 13; |
| 1281 int z15 = 15; |
1284 int z15 = 15; |
| 1282 int z42 = 42; |
1285 int z42 = 42; |