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 d38337ef489dd8315135d7242b033e1837b4af2f..204431ac98a4d8f56aa4d59ca58cd63bbe571fa6 100644 |
| --- a/base/containers/mru_cache_unittest.cc |
| +++ b/base/containers/mru_cache_unittest.cc |
| @@ -2,10 +2,13 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include "base/containers/mru_cache.h" |
| + |
| #include <stddef.h> |
| -#include "base/containers/mru_cache.h" |
| -#include "base/memory/scoped_ptr.h" |
| +#include <memory> |
|
Nico
2016/04/04 17:14:55
(nit: in a previous file that included ptr_util, y
dcheng
2016/04/04 17:43:38
The automated rules are this:
- scoped_ptr.h, if p
|
| + |
| +#include "base/memory/ptr_util.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| namespace { |
| @@ -188,15 +191,15 @@ TEST(MRUCacheTest, KeyReplacement) { |
| // Make sure that the owning version release its pointers properly. |
| TEST(MRUCacheTest, Owning) { |
| - using Cache = base::MRUCache<int, scoped_ptr<CachedItem>>; |
| + using Cache = base::MRUCache<int, std::unique_ptr<CachedItem>>; |
| 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, make_scoped_ptr(new CachedItem(20))); |
| - cache.Put(kItem1Key, make_scoped_ptr(new CachedItem(22))); |
| + cache.Put(kItem1Key, WrapUnique(new CachedItem(20))); |
| + cache.Put(kItem1Key, WrapUnique(new CachedItem(22))); |
| // There should still be one item, and one extra live item. |
| Cache::iterator iter = cache.Get(kItem1Key); |
| @@ -212,8 +215,8 @@ TEST(MRUCacheTest, Owning) { |
| // go away. |
| { |
| Cache cache2(Cache::NO_AUTO_EVICT); |
| - cache2.Put(1, make_scoped_ptr(new CachedItem(20))); |
| - cache2.Put(2, make_scoped_ptr(new CachedItem(20))); |
| + cache2.Put(1, WrapUnique(new CachedItem(20))); |
| + cache2.Put(2, WrapUnique(new CachedItem(20))); |
| } |
| // There should be no objects leaked. |
| @@ -222,8 +225,8 @@ TEST(MRUCacheTest, Owning) { |
| // Check that Clear() also frees things correctly. |
| { |
| Cache cache2(Cache::NO_AUTO_EVICT); |
| - cache2.Put(1, make_scoped_ptr(new CachedItem(20))); |
| - cache2.Put(2, make_scoped_ptr(new CachedItem(20))); |
| + cache2.Put(1, WrapUnique(new CachedItem(20))); |
| + cache2.Put(2, WrapUnique(new CachedItem(20))); |
| EXPECT_EQ(initial_count + 2, cached_item_live_count); |
| cache2.Clear(); |
| EXPECT_EQ(initial_count, cached_item_live_count); |
| @@ -231,7 +234,7 @@ TEST(MRUCacheTest, Owning) { |
| } |
| TEST(MRUCacheTest, AutoEvict) { |
| - using Cache = base::MRUCache<int, scoped_ptr<CachedItem>>; |
| + using Cache = base::MRUCache<int, std::unique_ptr<CachedItem>>; |
| static const Cache::size_type kMaxSize = 3; |
| int initial_count = cached_item_live_count; |
| @@ -240,10 +243,10 @@ TEST(MRUCacheTest, AutoEvict) { |
| Cache cache(kMaxSize); |
| static const int kItem1Key = 1, kItem2Key = 2, kItem3Key = 3, kItem4Key = 4; |
| - 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))); |
| + cache.Put(kItem1Key, WrapUnique(new CachedItem(20))); |
| + cache.Put(kItem2Key, WrapUnique(new CachedItem(21))); |
| + cache.Put(kItem3Key, WrapUnique(new CachedItem(22))); |
| + cache.Put(kItem4Key, WrapUnique(new CachedItem(23))); |
| // The cache should only have kMaxSize items in it even though we inserted |
| // more. |