Lines Matching refs:cache
33 LruCache<int, int> cache(3, "testing"); // capacity = 3; in TEST() local
34 cache.Put(1, 10); in TEST()
35 EXPECT_EQ(cache.Size(), 1); in TEST()
36 EXPECT_FALSE(cache.Put(2, 20)); in TEST()
37 EXPECT_FALSE(cache.Put(3, 30)); in TEST()
38 EXPECT_EQ(cache.Size(), 3); in TEST()
41 EXPECT_TRUE(cache.Get(1, value)); in TEST()
43 EXPECT_TRUE(cache.Get(2, value)); in TEST()
45 EXPECT_TRUE(cache.Get(3, value)); in TEST()
47 EXPECT_EQ(cache.Size(), 3); in TEST()
49 EXPECT_THAT(cache.Put(4, 40), Optional(Pair(1, 10))); in TEST()
51 EXPECT_FALSE(cache.Get(1, value)); in TEST()
52 EXPECT_TRUE(cache.Get(4, value)); in TEST()
54 EXPECT_TRUE(cache.Get(2, value)); in TEST()
56 EXPECT_TRUE(cache.Get(3, value)); in TEST()
59 EXPECT_THAT(cache.Put(5, 50), Optional(Pair(4, 40))); in TEST()
60 EXPECT_EQ(cache.Size(), 3); in TEST()
63 EXPECT_TRUE(cache.Remove(3)); in TEST()
64 EXPECT_FALSE(cache.Put(6, 60)); in TEST()
67 EXPECT_FALSE(cache.Get(3, value)); in TEST()
68 EXPECT_FALSE(cache.Get(4, value)); in TEST()
69 EXPECT_TRUE(cache.Get(2, value)); in TEST()
71 EXPECT_TRUE(cache.Get(5, value)); in TEST()
73 EXPECT_TRUE(cache.Get(6, value)); in TEST()
79 LruCache<int, int> cache(2, "testing"); // size = 2; in TEST() local
80 EXPECT_FALSE(cache.Put(1, 10)); in TEST()
81 EXPECT_FALSE(cache.Put(2, 20)); in TEST()
82 EXPECT_THAT(cache.Put(3, 30), Optional(Pair(1, 10))); in TEST()
83 EXPECT_FALSE(cache.Put(2, 200)); in TEST()
84 EXPECT_EQ(cache.Size(), 2); in TEST()
87 EXPECT_FALSE(cache.HasKey(1)); in TEST()
88 EXPECT_TRUE(cache.Get(2, value)); in TEST()
90 EXPECT_TRUE(cache.Get(3, value)); in TEST()
93 EXPECT_THAT(cache.Put(4, 40), Optional(Pair(2, 200))); in TEST()
96 EXPECT_FALSE(cache.HasKey(2)); in TEST()
97 EXPECT_TRUE(cache.Get(3, value)); in TEST()
99 EXPECT_TRUE(cache.Get(4, value)); in TEST()
102 EXPECT_TRUE(cache.Remove(4)); in TEST()
103 EXPECT_EQ(cache.Size(), 1); in TEST()
104 cache.Put(2, 2000); in TEST()
107 EXPECT_FALSE(cache.HasKey(4)); in TEST()
108 EXPECT_TRUE(cache.Get(3, value)); in TEST()
110 EXPECT_TRUE(cache.Get(2, value)); in TEST()
113 EXPECT_TRUE(cache.Remove(2)); in TEST()
114 EXPECT_TRUE(cache.Remove(3)); in TEST()
115 cache.Put(5, 50); in TEST()
116 cache.Put(1, 100); in TEST()
117 cache.Put(1, 1000); in TEST()
118 EXPECT_EQ(cache.Size(), 2); in TEST()
121 EXPECT_FALSE(cache.HasKey(2)); in TEST()
122 EXPECT_FALSE(cache.HasKey(3)); in TEST()
123 EXPECT_TRUE(cache.Get(1, value)); in TEST()
125 EXPECT_TRUE(cache.Get(5, value)); in TEST()
130 LruCache<int, int> cache(10, "testing"); in TEST() local
131 cache.Put(1, 10); in TEST()
132 cache.Put(2, 20); in TEST()
134 EXPECT_TRUE(cache.Get(1, &value)); in TEST()
136 auto value_ptr = cache.Find(1); in TEST()
139 EXPECT_TRUE(cache.Get(1, &value)); in TEST()
141 cache.Put(1, 40); in TEST()
143 EXPECT_EQ(cache.Find(10), nullptr); in TEST()
147 LruCache<int, int> cache(10, "testing"); in TEST() local
148 cache.Put(1, 10); in TEST()
149 cache.Put(2, 20); in TEST()
151 EXPECT_TRUE(cache.Get(1, &value)); in TEST()
153 EXPECT_TRUE(cache.HasKey(1)); in TEST()
154 EXPECT_TRUE(cache.HasKey(2)); in TEST()
155 EXPECT_FALSE(cache.HasKey(3)); in TEST()
156 EXPECT_FALSE(cache.Get(3, &value)); in TEST()
161 LruCache<int, int> cache(10, "testing"); in TEST() local
163 cache.Put(key, key * 100); in TEST()
166 EXPECT_FALSE(cache.HasKey(key)); in TEST()
169 EXPECT_TRUE(cache.HasKey(key)); in TEST()
172 EXPECT_TRUE(cache.Remove(key)); in TEST()
175 EXPECT_FALSE(cache.HasKey(key)); in TEST()
180 LruCache<int, int> cache(10, "testing"); in TEST() local
182 cache.Put(key, key * 100); in TEST()
185 EXPECT_TRUE(cache.HasKey(key)); in TEST()
187 cache.Clear(); in TEST()
189 EXPECT_FALSE(cache.HasKey(key)); in TEST()
193 cache.Put(key, key * 1000); in TEST()
196 EXPECT_TRUE(cache.HasKey(key)); in TEST()
203 LruCache<int, int> cache(static_cast<size_t>(max_size), "testing"); in TEST() local
207 cache.Put(key, key); in TEST()
212 EXPECT_TRUE(cache.HasKey(key)); in TEST()
218 cache.Put(new_key, new_key); in TEST()
219 EXPECT_FALSE(cache.HasKey(key)); in TEST()
220 EXPECT_TRUE(cache.HasKey(new_key)); in TEST()
226 EXPECT_TRUE(cache.Get(key, value)); in TEST()
228 EXPECT_TRUE(cache.Remove(key)); in TEST()
230 EXPECT_EQ(cache.Size(), 0); in TEST()
243 LruCache<int, int> cache(100, "testing"); in TEST() local
244 auto pointer = &cache; in TEST()
257 EXPECT_EQ(cache.Size(), 0); in TEST()