Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(924)

Unified Diff: base/containers/mru_cache_unittest.cc

Issue 1852433005: Convert //base to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after r384946 Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/command_line_unittest.cc ('k') | base/containers/scoped_ptr_hash_map.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « base/command_line_unittest.cc ('k') | base/containers/scoped_ptr_hash_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698