OLD | NEW |
(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 |
OLD | NEW |