diff -r 0d5447230044 -r 8c6edaccaef1 tests/test_map.cpp --- a/tests/test_map.cpp Sun May 21 14:04:34 2023 +0200 +++ b/tests/test_map.cpp Sun May 21 14:37:56 2023 +0200 @@ -472,3 +472,51 @@ cxMapDestroy(map); EXPECT_TRUE(allocator.verify()); } + +TEST(EmptyMap, Size) { + auto map = cxEmptyMap; + + EXPECT_EQ(map->size, 0); +} + +TEST(EmptyMap, Iterator) { + auto map = cxEmptyMap; + + auto it1 = cxMapIterator(map); + auto it2 = cxMapIteratorValues(map); + auto it3 = cxMapIteratorKeys(map); + auto it4 = cxMapMutIterator(map); + auto it5 = cxMapMutIteratorValues(map); + auto it6 = cxMapMutIteratorKeys(map); + + EXPECT_FALSE(cxIteratorValid(it1)); + EXPECT_FALSE(cxIteratorValid(it2)); + EXPECT_FALSE(cxIteratorValid(it3)); + EXPECT_FALSE(cxIteratorValid(it4)); + EXPECT_FALSE(cxIteratorValid(it5)); + EXPECT_FALSE(cxIteratorValid(it6)); + + int c = 0; + cx_foreach(void*, data, it1) c++; + cx_foreach(void*, data, it2) c++; + cx_foreach(void*, data, it3) c++; + cx_foreach(void*, data, it4) c++; + cx_foreach(void*, data, it5) c++; + cx_foreach(void*, data, it6) c++; + EXPECT_EQ(c, 0); +} + +TEST(EmptyMap, NoOps) { + auto map = cxEmptyMap; + + ASSERT_NO_FATAL_FAILURE(cxMapClear(map)); + ASSERT_NO_FATAL_FAILURE(cxMapRehash(map)); + ASSERT_NO_FATAL_FAILURE(cxMapDestroy(map)); +} + +TEST(EmptyMap, Get) { + auto map = cxEmptyMap; + + CxHashKey key = cx_hash_key_str("test"); + EXPECT_EQ(cxMapGet(map, key), nullptr); +}