• Home
  • Raw
  • Download

Lines Matching full:cache

84   typedef typename TypeParam::template Type<int, CachedItem> Cache;  in TYPED_TEST()  typedef
85 Cache cache(Cache::NO_AUTO_EVICT); in TYPED_TEST() local
90 EXPECT_TRUE(cache.Get(0) == cache.end()); in TYPED_TEST()
91 EXPECT_TRUE(cache.Peek(0) == cache.end()); in TYPED_TEST()
96 auto inserted_item = cache.Put(kItem1Key, item1); in TYPED_TEST()
97 EXPECT_EQ(1U, cache.size()); in TYPED_TEST()
101 auto found = cache.Get(kItem1Key); in TYPED_TEST()
102 EXPECT_TRUE(inserted_item == cache.begin()); in TYPED_TEST()
103 EXPECT_TRUE(found != cache.end()); in TYPED_TEST()
105 found = cache.Peek(kItem1Key); in TYPED_TEST()
106 EXPECT_TRUE(found != cache.end()); in TYPED_TEST()
114 cache.Put(kItem2Key, item2); in TYPED_TEST()
115 EXPECT_EQ(2U, cache.size()); in TYPED_TEST()
119 auto oldest = cache.rbegin(); in TYPED_TEST()
120 ASSERT_TRUE(oldest != cache.rend()); in TYPED_TEST()
127 auto test_item = cache.Get(kItem1Key); in TYPED_TEST()
128 ASSERT_TRUE(test_item != cache.end()); in TYPED_TEST()
135 auto oldest = cache.rbegin(); in TYPED_TEST()
136 ASSERT_TRUE(oldest != cache.rend()); in TYPED_TEST()
143 auto next = cache.Erase(cache.rbegin()); in TYPED_TEST()
145 EXPECT_EQ(1U, cache.size()); in TYPED_TEST()
147 EXPECT_TRUE(next == cache.rbegin()); in TYPED_TEST()
151 cache.Erase(cache.begin()); in TYPED_TEST()
152 EXPECT_EQ(0U, cache.size()); in TYPED_TEST()
156 cache.Put(kItem1Key, item1); in TYPED_TEST()
157 cache.Put(kItem2Key, item2); in TYPED_TEST()
158 EXPECT_EQ(2U, cache.size()); in TYPED_TEST()
159 cache.Clear(); in TYPED_TEST()
160 EXPECT_EQ(0U, cache.size()); in TYPED_TEST()
164 typedef typename TypeParam::template Type<int, CachedItem> Cache; in TYPED_TEST() typedef
165 Cache cache(Cache::NO_AUTO_EVICT); in TYPED_TEST() local
169 cache.Put(kItem1Key, item1); in TYPED_TEST()
173 cache.Put(kItem2Key, item2); in TYPED_TEST()
176 cache.ShrinkToSize(100); in TYPED_TEST()
180 auto iter = cache.rbegin(); in TYPED_TEST()
181 ASSERT_TRUE(iter != cache.rend()); in TYPED_TEST()
188 auto peekiter = cache.Peek(kItem1Key); in TYPED_TEST()
189 ASSERT_TRUE(peekiter != cache.end()); in TYPED_TEST()
191 auto iter = cache.rbegin(); in TYPED_TEST()
192 ASSERT_TRUE(iter != cache.rend()); in TYPED_TEST()
199 typedef typename TypeParam::template Type<int, CachedItem> Cache; in TYPED_TEST() typedef
200 Cache cache(Cache::NO_AUTO_EVICT); in TYPED_TEST() local
204 cache.Put(kItem1Key, item1); in TYPED_TEST()
208 cache.Put(kItem2Key, item2); in TYPED_TEST()
212 cache.Put(kItem3Key, item3); in TYPED_TEST()
216 cache.Put(kItem4Key, item4); in TYPED_TEST()
219 cache.Put(kItem3Key, item5); in TYPED_TEST()
221 EXPECT_EQ(4U, cache.size()); in TYPED_TEST()
223 auto iter = cache.rbegin(); in TYPED_TEST()
224 ASSERT_TRUE(iter != cache.rend()); in TYPED_TEST()
228 cache.ShrinkToSize(1); in TYPED_TEST()
230 auto iter = cache.begin(); in TYPED_TEST()
235 // Make sure that the cache release its pointers properly.
237 using Cache = in TYPED_TEST() typedef
239 Cache cache(Cache::NO_AUTO_EVICT); in TYPED_TEST() local
245 cache.Put(kItem1Key, std::make_unique<CachedItem>(20)); in TYPED_TEST()
246 cache.Put(kItem1Key, std::make_unique<CachedItem>(22)); in TYPED_TEST()
249 auto iter = cache.Get(kItem1Key); in TYPED_TEST()
250 EXPECT_EQ(1U, cache.size()); in TYPED_TEST()
251 EXPECT_TRUE(iter != cache.end()); in TYPED_TEST()
255 cache.Erase(cache.begin()); in TYPED_TEST()
258 // Now try another cache that goes out of scope to make sure its pointers in TYPED_TEST()
261 Cache cache2(Cache::NO_AUTO_EVICT); in TYPED_TEST()
271 Cache cache2(Cache::NO_AUTO_EVICT); in TYPED_TEST()
281 using Cache = in TYPED_TEST() typedef
283 static const typename Cache::size_type kMaxSize = 3; in TYPED_TEST()
288 Cache cache(kMaxSize); in TYPED_TEST() local
291 cache.Put(kItem1Key, std::make_unique<CachedItem>(20)); in TYPED_TEST()
292 cache.Put(kItem2Key, std::make_unique<CachedItem>(21)); in TYPED_TEST()
293 cache.Put(kItem3Key, std::make_unique<CachedItem>(22)); in TYPED_TEST()
294 cache.Put(kItem4Key, std::make_unique<CachedItem>(23)); in TYPED_TEST()
296 // The cache should only have kMaxSize items in it even though we inserted in TYPED_TEST()
298 EXPECT_EQ(kMaxSize, cache.size()); in TYPED_TEST()
306 // Very simple test to make sure that the hashing cache works correctly. in TYPED_TEST()
307 typedef typename TypeParam::template Type<std::string, CachedItem> Cache; in TYPED_TEST() typedef
308 Cache cache(Cache::NO_AUTO_EVICT); in TYPED_TEST() local
311 cache.Put("First", one); in TYPED_TEST()
314 cache.Put("Second", two); in TYPED_TEST()
316 EXPECT_EQ(one.value, cache.Get("First")->second.value); in TYPED_TEST()
317 EXPECT_EQ(two.value, cache.Get("Second")->second.value); in TYPED_TEST()
318 cache.ShrinkToSize(1); in TYPED_TEST()
319 EXPECT_EQ(two.value, cache.Get("Second")->second.value); in TYPED_TEST()
320 EXPECT_TRUE(cache.Get("First") == cache.end()); in TYPED_TEST()
324 typedef typename TypeParam::template Type<int, CachedItem> Cache; in TYPED_TEST() typedef
325 Cache cache1(Cache::NO_AUTO_EVICT); in TYPED_TEST()
352 Cache cache2(Cache::NO_AUTO_EVICT); in TYPED_TEST()
428 typedef typename TypeParam::template Type<std::string> Cache; in TYPED_TEST() typedef
429 Cache cache(Cache::NO_AUTO_EVICT); in TYPED_TEST() local
431 cache.Put("Hello"); in TYPED_TEST()
432 cache.Put("world"); in TYPED_TEST()
433 cache.Put("foo"); in TYPED_TEST()
434 cache.Put("bar"); in TYPED_TEST()
437 cache.Put("foo"); in TYPED_TEST()
440 auto r_iter = cache.rbegin(); in TYPED_TEST()
449 EXPECT_EQ(r_iter, cache.rend()); in TYPED_TEST()
452 auto iter = cache.begin(); in TYPED_TEST()
461 EXPECT_EQ(iter, cache.end()); in TYPED_TEST()
519 // This tests that upon replacing a duplicate element in the cache with `Put`,
529 using Cache = typename TypeParam::template Type<Ptr, DerefCompare<Ptr>>; in TYPED_TEST() typedef
530 return Cache(Cache::NO_AUTO_EVICT); in TYPED_TEST()
533 using Cache = typename TypeParam::template Type<Ptr, DerefHash<Ptr>, in TYPED_TEST() typedef
535 return Cache(Cache::NO_AUTO_EVICT); in TYPED_TEST()
543 auto cache = kCreateCache(); in TYPED_TEST() local
544 cache.Put(MakeRefCounted<Item>("Hello")); in TYPED_TEST()
545 cache.Put(MakeRefCounted<Item>("world")); in TYPED_TEST()
546 cache.Put(MakeRefCounted<Item>("foo")); in TYPED_TEST()
547 cache.Put(MakeRefCounted<Item>("bar")); in TYPED_TEST()
553 const auto* old_foo_addr = cache.Peek(foo)->get(); in TYPED_TEST()
554 auto iter = cache.Put(std::move(foo)); in TYPED_TEST()
560 auto r_iter = cache.rbegin(); in TYPED_TEST()
569 EXPECT_EQ(r_iter, cache.rend()); in TYPED_TEST()
572 auto iter = cache.begin(); in TYPED_TEST()
581 EXPECT_EQ(iter, cache.end()); in TYPED_TEST()
586 typedef typename TypeParam::template Type<std::string, int> Cache; in TYPED_TEST() typedef
587 Cache cache(10); in TYPED_TEST() local
590 cache.Put(key, 1); in TYPED_TEST()
592 EXPECT_GT(trace_event::EstimateMemoryUsage(cache), in TYPED_TEST()