| 4 | #include <cstring> |
| 5 | |
| 6 | TEST(SmFlatHashMap, InlineStorageTest01) |
| 7 | { |
| 8 | // create hash map and insert one element |
| 9 | Excalibur::HashTable<std::string, std::string, 8> ht; |
| 10 | |
| 11 | EXPECT_GE(ht.capacity(), uint32_t(4)); |
| 12 | |
| 13 | auto it1 = ht.emplace(std::string("hello1"), std::string("world1")); |
| 14 | EXPECT_TRUE(it1.second); |
| 15 | auto it2 = ht.emplace(std::string("hello2"), std::string("world2")); |
| 16 | EXPECT_TRUE(it2.second); |
| 17 | |
| 18 | EXPECT_EQ(ht.size(), uint32_t(2)); |
| 19 | |
| 20 | { |
| 21 | auto _it1 = ht.find("hello1"); |
| 22 | ASSERT_NE(_it1, ht.end()); |
| 23 | const std::string& val1 = _it1->second; |
| 24 | ASSERT_EQ(val1, "world1"); |
| 25 | |
| 26 | auto _it2 = ht.find("hello2"); |
| 27 | ASSERT_NE(_it2, ht.end()); |
| 28 | const std::string& val2 = _it2->second; |
| 29 | ASSERT_EQ(val2, "world2"); |
| 30 | } |
| 31 | |
| 32 | for (int i = 0; i < 1000; i++) |
| 33 | { |
| 34 | ht.emplace(std::to_string(i), "tmp"); |
| 35 | } |
| 36 | |
| 37 | { |
| 38 | auto _it1 = ht.find("hello1"); |
| 39 | ASSERT_NE(_it1, ht.end()); |
| 40 | const std::string& val1 = _it1->second; |
| 41 | ASSERT_EQ(val1, "world1"); |
| 42 | |
| 43 | auto _it2 = ht.find("hello2"); |
| 44 | ASSERT_NE(_it2, ht.end()); |
| 45 | const std::string& val2 = _it2->second; |
| 46 | ASSERT_EQ(val2, "world2"); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | static int ctorCallCount = 0; |
| 51 | static int dtorCallCount = 0; |
nothing calls this directly
no test coverage detected