MCPcopy Create free account
hub / github.com/apache/arrow / TEST_F

Function TEST_F

cpp/src/arrow/util/cache_test.cc:87–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85};
86
87TEST_F(TestLruCache, Basics) {
88 Cache cache(10);
89
90 using namespace std::placeholders; // NOLINT [build/namespaces]
91 auto Replace = std::bind(&TestLruCache::Replace, this, &cache, _1, _2);
92 auto Find = std::bind(&TestLruCache::Find, this, &cache, _1);
93
94 ASSERT_EQ(cache.size(), 0);
95 ASSERT_EQ(Find(100), nullptr);
96
97 // Insertions
98 ASSERT_TRUE(Replace(100, 100));
99 ASSERT_TRUE(Replace(101, 101));
100 ASSERT_TRUE(Replace(102, 102));
101 ASSERT_EQ(cache.size(), 3);
102 ASSERT_EQ(*Find(100), V{100});
103 ASSERT_EQ(*Find(101), V{101});
104 ASSERT_EQ(*Find(102), V{102});
105
106 // Replacements
107 ASSERT_FALSE(Replace(100, -100));
108 ASSERT_FALSE(Replace(101, -101));
109 ASSERT_FALSE(Replace(102, -102));
110 ASSERT_EQ(cache.size(), 3);
111 ASSERT_EQ(*Find(100), V{-100});
112 ASSERT_EQ(*Find(101), V{-101});
113 ASSERT_EQ(*Find(102), V{-102});
114
115 ASSERT_EQ(cache.size(), 3);
116 cache.Clear();
117 ASSERT_EQ(cache.size(), 0);
118}
119
120TEST_F(TestLruCache, Eviction) {
121 Cache cache(5);

Callers

nothing calls this directly

Calls 7

ReplaceFunction · 0.85
to_stringFunction · 0.85
emplace_backMethod · 0.80
FindFunction · 0.70
sizeMethod · 0.45
ClearMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected