-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathExcaliburHashTest06.cpp
More file actions
72 lines (55 loc) · 1.38 KB
/
ExcaliburHashTest06.cpp
File metadata and controls
72 lines (55 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "ExcaliburHash.h"
#include "gtest/gtest.h"
#include <array>
#include <cstring>
TEST(SmFlatHashMap, Rehash)
{
Excalibur::HashTable<int, int> ht;
ht.emplace(1, -1);
ht.erase(1);
ht.emplace(2, -2);
ht.emplace(5, -5);
ht.erase(5);
ht.emplace(7, -7);
ht.erase(7);
ht.emplace(8, -8);
ht.emplace(9, -9);
ht.erase(9);
ht.emplace(10, -10);
ht.erase(10);
ht.emplace(11, -11);
ht.erase(11);
ht.emplace(12, -12);
ht.erase(12);
ht.emplace(13, -13);
ht.erase(13);
ht.emplace(14, -14);
ht.erase(14);
ht.emplace(15, -15);
EXPECT_GE(ht.getNumTombstones(), uint32_t(1));
ht.rehash();
EXPECT_EQ(ht.getNumTombstones(), uint32_t(0));
}
TEST(SmFlatHashMap, TestTmp)
{
class StringInternStringData
{
public:
inline StringInternStringData()
: refCount(0)
, string()
{
}
inline StringInternStringData(const std::string& string)
: refCount(1)
, string(string)
{
}
int64_t refCount;
std::string string;
};
Excalibur::HashTable<std::string, std::unique_ptr<StringInternStringData>> exMap;
auto inserted = exMap.emplace(std::string("test"), std::make_unique<StringInternStringData>("test"));
EXPECT_EQ(inserted.second, true);
EXPECT_NE(inserted.first, exMap.end());
}