| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/containers/mru_cache.h" | 6 #include "base/containers/mru_cache.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/googletest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 namespace { | 9 namespace { |
| 10 | 10 |
| 11 int cached_item_live_count = 0; | 11 int cached_item_live_count = 0; |
| 12 | 12 |
| 13 struct CachedItem { | 13 struct CachedItem { |
| 14 CachedItem() : value(0) { | 14 CachedItem() : value(0) { |
| 15 cached_item_live_count++; | 15 cached_item_live_count++; |
| 16 } | 16 } |
| 17 | 17 |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 | 262 |
| 263 CachedItem two(2); | 263 CachedItem two(2); |
| 264 cache.Put("Second", two); | 264 cache.Put("Second", two); |
| 265 | 265 |
| 266 EXPECT_EQ(one.value, cache.Get("First")->second.value); | 266 EXPECT_EQ(one.value, cache.Get("First")->second.value); |
| 267 EXPECT_EQ(two.value, cache.Get("Second")->second.value); | 267 EXPECT_EQ(two.value, cache.Get("Second")->second.value); |
| 268 cache.ShrinkToSize(1); | 268 cache.ShrinkToSize(1); |
| 269 EXPECT_EQ(two.value, cache.Get("Second")->second.value); | 269 EXPECT_EQ(two.value, cache.Get("Second")->second.value); |
| 270 EXPECT_TRUE(cache.Get("First") == cache.end()); | 270 EXPECT_TRUE(cache.Get("First") == cache.end()); |
| 271 } | 271 } |
| OLD | NEW |