MCPcopy Create free account
hub / github.com/Snapchat/Valdi / TEST

Function TEST

valdi/test/runtime/LRUCache_tests.cpp:9–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7namespace ValdiTest {
8
9TEST(LRUCache, canInsertAndGet) {
10 LRUCache<StringBox, int> cache(16);
11
12 cache.insert(STRING_LITERAL("KeyA"), 1);
13 cache.insert(STRING_LITERAL("KeyB"), 2);
14 cache.insert(STRING_LITERAL("KeyC"), 3);
15
16 ASSERT_EQ(static_cast<size_t>(3), cache.size());
17
18 ASSERT_TRUE(cache.contains(STRING_LITERAL("KeyA")));
19 ASSERT_TRUE(cache.contains(STRING_LITERAL("KeyB")));
20 ASSERT_TRUE(cache.contains(STRING_LITERAL("KeyC")));
21 ASSERT_FALSE(cache.contains(STRING_LITERAL("KeyD")));
22
23 auto it = cache.find(STRING_LITERAL("KeyA"));
24
25 ASSERT_TRUE(it != cache.end());
26 ASSERT_EQ(1, it->value());
27
28 it = cache.find(STRING_LITERAL("KeyB"));
29
30 ASSERT_TRUE(it != cache.end());
31 ASSERT_EQ(2, it->value());
32
33 it = cache.find(STRING_LITERAL("KeyC"));
34
35 ASSERT_TRUE(it != cache.end());
36 ASSERT_EQ(3, it->value());
37
38 it = cache.find(STRING_LITERAL("KeyD"));
39
40 ASSERT_TRUE(it == cache.end());
41}
42
43TEST(LRUCache, canRemove) {
44 LRUCache<StringBox, int> cache(16);

Callers

nothing calls this directly

Calls 12

setCapacityMethod · 0.80
insertMethod · 0.65
containsMethod · 0.65
endMethod · 0.65
valueMethod · 0.65
removeMethod · 0.65
clearMethod · 0.65
sizeMethod · 0.45
findMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45
keyMethod · 0.45

Tested by

no test coverage detected