Add FlatHashSet initialization test.

This commit is contained in:
levlam 2023-05-18 13:51:27 +03:00
parent bd480941a1
commit 46b6ba578f

View File

@ -92,6 +92,20 @@ static bool operator==(const A &lhs, const A &rhs) {
return lhs.a == rhs.a;
}
TEST(FlatHashSet, init) {
td::FlatHashSet<td::Slice, td::SliceHash> s{"1", "22", "333", "4444"};
ASSERT_TRUE(s.size() == 4);
td::string str("1");
ASSERT_TRUE(s.count(str) == 1);
ASSERT_TRUE(s.count("1") == 1);
ASSERT_TRUE(s.count("22") == 1);
ASSERT_TRUE(s.count("333") == 1);
ASSERT_TRUE(s.count("4444") == 1);
ASSERT_TRUE(s.count("4") == 0);
ASSERT_TRUE(s.count("222") == 0);
ASSERT_TRUE(s.count("") == 0);
}
TEST(FlatHashSet, foreach) {
td::FlatHashSet<A, AHash> s;
for (auto it : s) {