MCPcopy Create free account
hub / github.com/cwida/ALP / TEST

Function TEST

publication/source_code/bench_end_to_end/src/test/common/Hashmap.cpp:16–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14};
15
16TEST(Hashtable, insertAndFind) {
17 Hashmap ht;
18 const auto nrEntries = 5;
19 ht.setSize(nrEntries);
20 std::vector<Entry> entries;
21 entries.reserve(nrEntries);
22 for (int i = 0; i < nrEntries; ++i) {
23 entries.push_back(Entry());
24 auto& e = entries.back();
25 e.k = i;
26 e.v = i + 50;
27 e.h.hash = std::hash<uint64_t>()(e.k);
28 ht.insert(&e.h, e.h.hash);
29 }
30
31 for (unsigned i = 0; i < nrEntries; ++i) {
32 auto hash = std::hash<uint64_t>()(i);
33 auto entry = ht.find_chain(hash);
34 bool found = false;
35 for (; entry != ht.end(); entry = entry->next)
36 if (reinterpret_cast<uint64_t*>(entry)[3] == i + 50) found = true;
37 ASSERT_EQ(found, true);
38 }
39}

Callers

nothing calls this directly

Calls 6

find_chainMethod · 0.80
EntryClass · 0.70
setSizeMethod · 0.45
push_backMethod · 0.45
insertMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected