tests/test_map.cpp

changeset 668
d7129285ac32
parent 659
4a06fd63909a
child 669
dce9b8450656
     1.1 --- a/tests/test_map.cpp	Tue Mar 21 17:18:29 2023 +0100
     1.2 +++ b/tests/test_map.cpp	Tue Mar 21 17:21:20 2023 +0100
     1.3 @@ -135,6 +135,23 @@
     1.4      EXPECT_TRUE(allocator.verify());
     1.5  }
     1.6  
     1.7 +TEST(CxHashMap, CreateForStoringPointers) {
     1.8 +    CxTestingAllocator allocator;
     1.9 +    auto map = cxHashMapCreate(&allocator, CX_STORE_POINTERS, 0);
    1.10 +    auto hmap = reinterpret_cast<struct cx_hash_map_s *>(map);
    1.11 +    EXPECT_GT(hmap->bucket_count, 0);
    1.12 +    cx_for_n(i, hmap->bucket_count) {
    1.13 +        EXPECT_EQ(hmap->buckets[i], nullptr);
    1.14 +    }
    1.15 +    EXPECT_EQ(map->size, 0);
    1.16 +    EXPECT_EQ(map->allocator, &allocator);
    1.17 +    EXPECT_TRUE(map->store_pointers);
    1.18 +    EXPECT_EQ(map->itemsize, sizeof(void *));
    1.19 +
    1.20 +    cxMapDestroy(map);
    1.21 +    EXPECT_TRUE(allocator.verify());
    1.22 +}
    1.23 +
    1.24  TEST(CxHashMap, BasicOperations) {
    1.25      // create the map
    1.26      CxTestingAllocator allocator;

mercurial