Chromium Code Reviews| Index: base/containers/mru_cache_unittest.cc |
| diff --git a/base/containers/mru_cache_unittest.cc b/base/containers/mru_cache_unittest.cc |
| index 8ebecdb7b62af008e450315f37ae42c36f9327a5..17bfc779d0fd02bcdd1423d76ae0e831790a7171 100644 |
| --- a/base/containers/mru_cache_unittest.cc |
| +++ b/base/containers/mru_cache_unittest.cc |
| @@ -5,6 +5,7 @@ |
| #include <stddef.h> |
| #include "base/containers/mru_cache.h" |
| +#include "base/memory/scoped_ptr.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| namespace { |
| @@ -187,15 +188,15 @@ TEST(MRUCacheTest, KeyReplacement) { |
| // Make sure that the owning version release its pointers properly. |
| TEST(MRUCacheTest, Owning) { |
| - typedef base::OwningMRUCache<int, CachedItem*> Cache; |
| + typedef base::MRUCache<int, scoped_ptr<CachedItem>> Cache; |
|
danakj
2016/03/07 21:27:10
dittos
vmpstr
2016/03/07 21:45:32
Done.
|
| Cache cache(Cache::NO_AUTO_EVICT); |
| int initial_count = cached_item_live_count; |
| // First insert and item and then overwrite it. |
| static const int kItem1Key = 1; |
| - cache.Put(kItem1Key, new CachedItem(20)); |
| - cache.Put(kItem1Key, new CachedItem(22)); |
| + cache.Put(kItem1Key, make_scoped_ptr(new CachedItem(20))); |
| + cache.Put(kItem1Key, make_scoped_ptr(new CachedItem(22))); |
| // There should still be one item, and one extra live item. |
| Cache::iterator iter = cache.Get(kItem1Key); |
| @@ -211,8 +212,8 @@ TEST(MRUCacheTest, Owning) { |
| // go away. |
| { |
| Cache cache2(Cache::NO_AUTO_EVICT); |
| - cache2.Put(1, new CachedItem(20)); |
| - cache2.Put(2, new CachedItem(20)); |
| + cache2.Put(1, make_scoped_ptr(new CachedItem(20))); |
| + cache2.Put(2, make_scoped_ptr(new CachedItem(20))); |
| } |
| // There should be no objects leaked. |
| @@ -221,8 +222,8 @@ TEST(MRUCacheTest, Owning) { |
| // Check that Clear() also frees things correctly. |
| { |
| Cache cache2(Cache::NO_AUTO_EVICT); |
| - cache2.Put(1, new CachedItem(20)); |
| - cache2.Put(2, new CachedItem(20)); |
| + cache2.Put(1, make_scoped_ptr(new CachedItem(20))); |
| + cache2.Put(2, make_scoped_ptr(new CachedItem(20))); |
| EXPECT_EQ(initial_count + 2, cached_item_live_count); |
| cache2.Clear(); |
| EXPECT_EQ(initial_count, cached_item_live_count); |
| @@ -230,7 +231,7 @@ TEST(MRUCacheTest, Owning) { |
| } |
| TEST(MRUCacheTest, AutoEvict) { |
| - typedef base::OwningMRUCache<int, CachedItem*> Cache; |
| + typedef base::MRUCache<int, scoped_ptr<CachedItem>> Cache; |
|
danakj
2016/03/07 21:27:10
dittoss
vmpstr
2016/03/07 21:45:32
Done.
|
| static const Cache::size_type kMaxSize = 3; |
| int initial_count = cached_item_live_count; |
| @@ -239,10 +240,10 @@ TEST(MRUCacheTest, AutoEvict) { |
| Cache cache(kMaxSize); |
| static const int kItem1Key = 1, kItem2Key = 2, kItem3Key = 3, kItem4Key = 4; |
| - cache.Put(kItem1Key, new CachedItem(20)); |
| - cache.Put(kItem2Key, new CachedItem(21)); |
| - cache.Put(kItem3Key, new CachedItem(22)); |
| - cache.Put(kItem4Key, new CachedItem(23)); |
| + cache.Put(kItem1Key, make_scoped_ptr(new CachedItem(20))); |
| + cache.Put(kItem2Key, make_scoped_ptr(new CachedItem(21))); |
| + cache.Put(kItem3Key, make_scoped_ptr(new CachedItem(22))); |
| + cache.Put(kItem4Key, make_scoped_ptr(new CachedItem(23))); |
| // The cache should only have kMaxSize items in it even though we inserted |
| // more. |