| 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..99b14d1ab5df59923a7133363b5f0c0f5fcca037 100644
|
| --- a/base/containers/mru_cache_unittest.cc
|
| +++ b/base/containers/mru_cache_unittest.cc
|
| @@ -2,12 +2,17 @@
|
| // 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>
|
| +
|
| +#include "base/memory/ptr_util.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| +namespace base {
|
| +
|
| namespace {
|
|
|
| int cached_item_live_count = 0;
|
| @@ -188,15 +193,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 +217,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 +227,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 +236,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 +245,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.
|
| @@ -375,3 +380,5 @@ TEST(MRUCacheTest, Swap) {
|
| EXPECT_EQ(item1.value, iter->second.value);
|
| }
|
| }
|
| +
|
| +} // namespace base
|
|
|