test/test_map.cpp

changeset 595
0da254bf23e6
parent 594
d90cfa6721f9
child 604
056e5f592d84
equal deleted inserted replaced
594:d90cfa6721f9 595:0da254bf23e6
252 } 252 }
253 253
254 TEST(CxHashMap, Clear) { 254 TEST(CxHashMap, Clear) {
255 CxTestingAllocator allocator; 255 CxTestingAllocator allocator;
256 auto map = cxHashMapCreate(&allocator, 0); 256 auto map = cxHashMapCreate(&allocator, 0);
257 auto hmap = reinterpret_cast<struct cx_hash_map_s *>(map); 257
258 EXPECT_GT(hmap->bucket_count, 0);
259 cx_for_n(i, hmap->bucket_count) {
260 EXPECT_EQ(hmap->buckets[i], nullptr);
261 }
262 EXPECT_EQ(map->size, 0);
263 EXPECT_EQ(map->allocator, &allocator);
264
265 cxMapPut(map, cx_hash_key_str("key 1"), (void *) "val 1"); 258 cxMapPut(map, cx_hash_key_str("key 1"), (void *) "val 1");
266 cxMapPut(map, cx_hash_key_str("key 2"), (void *) "val 2"); 259 cxMapPut(map, cx_hash_key_str("key 2"), (void *) "val 2");
267 cxMapPut(map, cx_hash_key_str("key 3"), (void *) "val 3"); 260 cxMapPut(map, cx_hash_key_str("key 3"), (void *) "val 3");
268 261
269 EXPECT_EQ(map->size, 3); 262 EXPECT_EQ(map->size, 3);

mercurial