std::vector<int> deleted_keys_;
std::vector<int> deleted_values_;
- shared_ptr<Cache> cache_;
- shared_ptr<Cache> cache2_;
+ std::shared_ptr<Cache> cache_;
+ std::shared_ptr<Cache> cache2_;
CacheTest()
: cache_(NewCache(kCacheSize, kNumShardBits, false)),
current_ = this;
}
- ~CacheTest() {
- }
+ ~CacheTest() override {}
std::shared_ptr<Cache> NewCache(size_t capacity) {
auto type = GetParam();
return nullptr;
}
- int Lookup(shared_ptr<Cache> cache, int key) {
+ int Lookup(std::shared_ptr<Cache> cache, int key) {
Cache::Handle* handle = cache->Lookup(EncodeKey(key));
const int r = (handle == nullptr) ? -1 : DecodeValue(cache->Value(handle));
if (handle != nullptr) {
return r;
}
- void Insert(shared_ptr<Cache> cache, int key, int value, int charge = 1) {
+ void Insert(std::shared_ptr<Cache> cache, int key, int value,
+ int charge = 1) {
cache->Insert(EncodeKey(key), EncodeValue(value), charge,
&CacheTest::Deleter);
}
- void Erase(shared_ptr<Cache> cache, int key) {
+ void Erase(std::shared_ptr<Cache> cache, int key) {
cache->Erase(EncodeKey(key));
}
-
int Lookup(int key) {
return Lookup(cache_, key);
}
CacheTest* CacheTest::current_;
TEST_P(CacheTest, UsageTest) {
- // cache is shared_ptr and will be automatically cleaned up.
+ // cache is std::shared_ptr and will be automatically cleaned up.
const uint64_t kCapacity = 100000;
auto cache = NewCache(kCapacity, 8, false);
}
TEST_P(CacheTest, PinnedUsageTest) {
- // cache is shared_ptr and will be automatically cleaned up.
+ // cache is std::shared_ptr and will be automatically cleaned up.
const uint64_t kCapacity = 100000;
auto cache = NewCache(kCapacity, 8, false);
Insert(200, 201);
// Frequently used entry must be kept around
- for (int i = 0; i < kCacheSize + 100; i++) {
+ for (int i = 0; i < kCacheSize + 200; i++) {
Insert(1000+i, 2000+i);
ASSERT_EQ(101, Lookup(100));
}
Insert(303, 104);
// Insert entries much more than Cache capacity
- for (int i = 0; i < kCacheSize + 100; i++) {
+ for (int i = 0; i < kCacheSize + 200; i++) {
Insert(1000 + i, 2000 + i);
}
}
#ifdef SUPPORT_CLOCK_CACHE
-shared_ptr<Cache> (*new_clock_cache_func)(size_t, int, bool) = NewClockCache;
+std::shared_ptr<Cache> (*new_clock_cache_func)(size_t, int,
+ bool) = NewClockCache;
INSTANTIATE_TEST_CASE_P(CacheTestInstance, CacheTest,
testing::Values(kLRU, kClock));
#else