Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: base/lru_bounded_cache_unittest.cc

Issue 1868353003: Add an LRUBoundedCache class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/lru_bounded_cache.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/lru_bounded_cache.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 namespace base {
10
11 TEST(LRUBoundedCacheTest, Basic) {
12 LRUBoundedCache<int> cache(3);
13
14 EXPECT_FALSE(cache.Insert(1));
15 EXPECT_EQ(1UL, cache.Size());
16
17 EXPECT_TRUE(cache.Insert(1));
18 EXPECT_EQ(1UL, cache.Size());
19
20 EXPECT_FALSE(cache.Insert(2));
21 EXPECT_EQ(2UL, cache.Size());
22
23 EXPECT_FALSE(cache.Insert(3));
24 EXPECT_EQ(3UL, cache.Size());
25
26 EXPECT_TRUE(cache.Insert(3));
27 EXPECT_EQ(3UL, cache.Size());
28
29 EXPECT_FALSE(cache.Insert(4));
30 EXPECT_EQ(3UL, cache.Size());
31
32 EXPECT_FALSE(cache.Insert(1));
33 EXPECT_EQ(3UL, cache.Size());
34 }
35
36 } // namespace base
OLDNEW
« no previous file with comments | « base/lru_bounded_cache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698