MCPcopy Create free account
hub / github.com/SergeyMakeev/ExcaliburHash / TEST

Function TEST

ExcaliburHashTest03.cpp:28–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26} // namespace Excalibur
27
28TEST(SmFlatHashMap, BadHashFunction)
29{
30 Excalibur::HashTable<CustomStruct, int> ht;
31 EXPECT_TRUE(ht.empty());
32 EXPECT_EQ(ht.size(), 0u);
33 EXPECT_GE(ht.capacity(), 0u);
34
35 const int kNumElements = 500;
36 for (int i = 0; i < kNumElements; i++)
37 {
38 int v = 3 + i;
39 auto it = ht.emplace(CustomStruct{256 * i + 1}, v);
40 EXPECT_TRUE(it.second);
41 }
42
43 for (int i = 0; i < kNumElements; i++)
44 {
45 auto v = ht.find(CustomStruct{256 * i + 1});
46 ASSERT_NE(v, ht.iend());
47 int refVal = 3 + i;
48 EXPECT_EQ(v.value(), refVal);
49 }
50
51 // search for non-existing keys
52 auto f0 = ht.find(CustomStruct{-3});
53 EXPECT_EQ(f0, ht.iend());
54 auto f1 = ht.find(CustomStruct{-13});
55 EXPECT_EQ(f1, ht.iend());
56
57 // erase non-existing keys
58 bool e0 = ht.erase(CustomStruct{-3});
59 EXPECT_FALSE(e0);
60 bool e1 = ht.erase(CustomStruct{-13});
61 EXPECT_FALSE(e1);
62}
63
64TEST(SmFlatHashMap, EmplaceEdgeCase)
65{

Callers

nothing calls this directly

Calls 7

ConstCorrectnessTestFunction · 0.85
MutabilityTestFunction · 0.85
makeTinyHashTableFunction · 0.85
makeHugeHashTableFunction · 0.85
makeHashTableFunction · 0.85
valueMethod · 0.80
endMethod · 0.45

Tested by

no test coverage detected