122 EXPECT_EQ(hmap->buckets[i], nullptr); |
122 EXPECT_EQ(hmap->buckets[i], nullptr); |
123 } |
123 } |
124 EXPECT_EQ(map->item_size, 1); |
124 EXPECT_EQ(map->item_size, 1); |
125 EXPECT_EQ(map->size, 0); |
125 EXPECT_EQ(map->size, 0); |
126 EXPECT_EQ(map->allocator, &allocator); |
126 EXPECT_EQ(map->allocator, &allocator); |
127 EXPECT_FALSE(map->store_pointers); |
127 EXPECT_FALSE(map->store_pointer); |
|
128 EXPECT_EQ(map->cmpfunc, nullptr); |
|
129 EXPECT_EQ(map->simple_destructor, nullptr); |
|
130 EXPECT_EQ(map->advanced_destructor, nullptr); |
|
131 EXPECT_EQ(map->destructor_data, nullptr); |
128 cxMapStorePointers(map); |
132 cxMapStorePointers(map); |
129 EXPECT_TRUE(map->store_pointers); |
133 EXPECT_TRUE(map->store_pointer); |
130 EXPECT_EQ(map->item_size, sizeof(void *)); |
134 EXPECT_EQ(map->item_size, sizeof(void *)); |
131 cxMapStoreObjects(map); |
135 cxMapStoreObjects(map); |
132 EXPECT_FALSE(map->store_pointers); |
136 EXPECT_FALSE(map->store_pointer); |
133 |
137 |
134 cxMapDestroy(map); |
138 cxMapDestroy(map); |
135 EXPECT_TRUE(allocator.verify()); |
139 EXPECT_TRUE(allocator.verify()); |
136 } |
140 } |
137 |
141 |
143 cx_for_n(i, hmap->bucket_count) { |
147 cx_for_n(i, hmap->bucket_count) { |
144 EXPECT_EQ(hmap->buckets[i], nullptr); |
148 EXPECT_EQ(hmap->buckets[i], nullptr); |
145 } |
149 } |
146 EXPECT_EQ(map->size, 0); |
150 EXPECT_EQ(map->size, 0); |
147 EXPECT_EQ(map->allocator, &allocator); |
151 EXPECT_EQ(map->allocator, &allocator); |
148 EXPECT_TRUE(map->store_pointers); |
152 EXPECT_TRUE(map->store_pointer); |
149 EXPECT_EQ(map->item_size, sizeof(void *)); |
153 EXPECT_EQ(map->item_size, sizeof(void *)); |
150 |
154 |
151 cxMapDestroy(map); |
155 cxMapDestroy(map); |
152 EXPECT_TRUE(allocator.verify()); |
156 EXPECT_TRUE(allocator.verify()); |
153 } |
157 } |
300 // create the map |
304 // create the map |
301 CxTestingAllocator allocator; |
305 CxTestingAllocator allocator; |
302 auto map = cxHashMapCreate(&allocator, sizeof(cxstring), 8); |
306 auto map = cxHashMapCreate(&allocator, sizeof(cxstring), 8); |
303 |
307 |
304 // define some strings |
308 // define some strings |
305 cxstring s1 = CX_STR("this"); |
309 auto s1 = CX_STR("this"); |
306 cxstring s2 = CX_STR("is"); |
310 auto s2 = CX_STR("is"); |
307 cxstring s3 = CX_STR("a"); |
311 auto s3 = CX_STR("a"); |
308 cxstring s4 = CX_STR("test"); |
312 auto s4 = CX_STR("test"); |
309 cxstring s5 = CX_STR("setup"); |
313 auto s5 = CX_STR("setup"); |
310 |
314 |
311 // put them into the map |
315 // put them into the map |
312 cxMapPut(map, cx_hash_key_str("s1"), &s1); |
316 cxMapPut(map, cx_hash_key_str("s1"), &s1); |
313 cxMapPut(map, cx_hash_key_str("s2"), &s2); |
317 cxMapPut(map, cx_hash_key_str("s2"), &s2); |
314 cxMapPut(map, cx_hash_key_str("s3"), &s3); |
318 cxMapPut(map, cx_hash_key_str("s3"), &s3); |