Lines Matching full:cache
43 typedef base::MRUCache<int, CachedItem> Cache; in TEST() typedef
44 Cache cache(Cache::NO_AUTO_EVICT); in TEST() local
49 EXPECT_TRUE(cache.Get(0) == cache.end()); in TEST()
50 EXPECT_TRUE(cache.Peek(0) == cache.end()); in TEST()
55 Cache::iterator inserted_item = cache.Put(kItem1Key, item1); in TEST()
56 EXPECT_EQ(1U, cache.size()); in TEST()
60 Cache::iterator found = cache.Get(kItem1Key); in TEST()
61 EXPECT_TRUE(inserted_item == cache.begin()); in TEST()
62 EXPECT_TRUE(found != cache.end()); in TEST()
64 found = cache.Peek(kItem1Key); in TEST()
65 EXPECT_TRUE(found != cache.end()); in TEST()
73 cache.Put(kItem2Key, item2); in TEST()
74 EXPECT_EQ(2U, cache.size()); in TEST()
78 Cache::reverse_iterator oldest = cache.rbegin(); in TEST()
79 ASSERT_TRUE(oldest != cache.rend()); in TEST()
86 Cache::iterator test_item = cache.Get(kItem1Key); in TEST()
87 ASSERT_TRUE(test_item != cache.end()); in TEST()
94 Cache::reverse_iterator oldest = cache.rbegin(); in TEST()
95 ASSERT_TRUE(oldest != cache.rend()); in TEST()
102 Cache::reverse_iterator next = cache.Erase(cache.rbegin()); in TEST()
104 EXPECT_EQ(1U, cache.size()); in TEST()
106 EXPECT_TRUE(next == cache.rbegin()); in TEST()
110 cache.Erase(cache.begin()); in TEST()
111 EXPECT_EQ(0U, cache.size()); in TEST()
115 cache.Put(kItem1Key, item1); in TEST()
116 cache.Put(kItem2Key, item2); in TEST()
117 EXPECT_EQ(2U, cache.size()); in TEST()
118 cache.Clear(); in TEST()
119 EXPECT_EQ(0U, cache.size()); in TEST()
123 typedef base::MRUCache<int, CachedItem> Cache; in TEST() typedef
124 Cache cache(Cache::NO_AUTO_EVICT); in TEST() local
128 cache.Put(kItem1Key, item1); in TEST()
132 cache.Put(kItem2Key, item2); in TEST()
135 cache.ShrinkToSize(100); in TEST()
139 Cache::reverse_iterator iter = cache.rbegin(); in TEST()
140 ASSERT_TRUE(iter != cache.rend()); in TEST()
147 Cache::iterator peekiter = cache.Peek(kItem1Key); in TEST()
148 ASSERT_TRUE(peekiter != cache.end()); in TEST()
150 Cache::reverse_iterator iter = cache.rbegin(); in TEST()
151 ASSERT_TRUE(iter != cache.rend()); in TEST()
158 typedef base::MRUCache<int, CachedItem> Cache; in TEST() typedef
159 Cache cache(Cache::NO_AUTO_EVICT); in TEST() local
163 cache.Put(kItem1Key, item1); in TEST()
167 cache.Put(kItem2Key, item2); in TEST()
171 cache.Put(kItem3Key, item3); in TEST()
175 cache.Put(kItem4Key, item4); in TEST()
178 cache.Put(kItem3Key, item5); in TEST()
180 EXPECT_EQ(4U, cache.size()); in TEST()
182 Cache::reverse_iterator iter = cache.rbegin(); in TEST()
183 ASSERT_TRUE(iter != cache.rend()); in TEST()
187 cache.ShrinkToSize(1); in TEST()
189 Cache::iterator iter = cache.begin(); in TEST()
196 using Cache = base::MRUCache<int, std::unique_ptr<CachedItem>>; in TEST() typedef
197 Cache cache(Cache::NO_AUTO_EVICT); in TEST() local
203 cache.Put(kItem1Key, WrapUnique(new CachedItem(20))); in TEST()
204 cache.Put(kItem1Key, WrapUnique(new CachedItem(22))); in TEST()
207 Cache::iterator iter = cache.Get(kItem1Key); in TEST()
208 EXPECT_EQ(1U, cache.size()); in TEST()
209 EXPECT_TRUE(iter != cache.end()); in TEST()
213 cache.Erase(cache.begin()); in TEST()
216 // Now try another cache that goes out of scope to make sure its pointers in TEST()
219 Cache cache2(Cache::NO_AUTO_EVICT); in TEST()
229 Cache cache2(Cache::NO_AUTO_EVICT); in TEST()
239 using Cache = base::MRUCache<int, std::unique_ptr<CachedItem>>; in TEST() typedef
240 static const Cache::size_type kMaxSize = 3; in TEST()
245 Cache cache(kMaxSize); in TEST() local
248 cache.Put(kItem1Key, std::make_unique<CachedItem>(20)); in TEST()
249 cache.Put(kItem2Key, std::make_unique<CachedItem>(21)); in TEST()
250 cache.Put(kItem3Key, std::make_unique<CachedItem>(22)); in TEST()
251 cache.Put(kItem4Key, std::make_unique<CachedItem>(23)); in TEST()
253 // The cache should only have kMaxSize items in it even though we inserted in TEST()
255 EXPECT_EQ(kMaxSize, cache.size()); in TEST()
263 // Very simple test to make sure that the hashing cache works correctly. in TEST()
264 typedef base::HashingMRUCache<std::string, CachedItem> Cache; in TEST() typedef
265 Cache cache(Cache::NO_AUTO_EVICT); in TEST() local
268 cache.Put("First", one); in TEST()
271 cache.Put("Second", two); in TEST()
273 EXPECT_EQ(one.value, cache.Get("First")->second.value); in TEST()
274 EXPECT_EQ(two.value, cache.Get("Second")->second.value); in TEST()
275 cache.ShrinkToSize(1); in TEST()
276 EXPECT_EQ(two.value, cache.Get("Second")->second.value); in TEST()
277 EXPECT_TRUE(cache.Get("First") == cache.end()); in TEST()
281 typedef base::MRUCache<int, CachedItem> Cache; in TEST() typedef
282 Cache cache1(Cache::NO_AUTO_EVICT); in TEST()
287 Cache::iterator inserted_item = cache1.Put(kItem1Key, item1); in TEST()
297 Cache::iterator iter = cache1.begin(); in TEST()
309 Cache cache2(Cache::NO_AUTO_EVICT); in TEST()
329 Cache::iterator iter = cache2.begin(); in TEST()
354 Cache::iterator iter = cache1.begin(); in TEST()
372 Cache::iterator iter = cache2.begin(); in TEST()
385 base::MRUCache<std::string, int> cache(10); in TEST() local
388 cache.Put(key, 1); in TEST()
390 EXPECT_GT(trace_event::EstimateMemoryUsage(cache), in TEST()