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

Side by Side Diff: base/containers/mru_cache_unittest.cc

Issue 2258713003: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | base/debug/activity_analyzer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/containers/mru_cache.h" 5 #include "base/containers/mru_cache.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 TEST(MRUCacheTest, AutoEvict) { 238 TEST(MRUCacheTest, AutoEvict) {
239 using Cache = base::MRUCache<int, std::unique_ptr<CachedItem>>; 239 using Cache = base::MRUCache<int, std::unique_ptr<CachedItem>>;
240 static const Cache::size_type kMaxSize = 3; 240 static const Cache::size_type kMaxSize = 3;
241 241
242 int initial_count = cached_item_live_count; 242 int initial_count = cached_item_live_count;
243 243
244 { 244 {
245 Cache cache(kMaxSize); 245 Cache cache(kMaxSize);
246 246
247 static const int kItem1Key = 1, kItem2Key = 2, kItem3Key = 3, kItem4Key = 4; 247 static const int kItem1Key = 1, kItem2Key = 2, kItem3Key = 3, kItem4Key = 4;
248 cache.Put(kItem1Key, WrapUnique(new CachedItem(20))); 248 cache.Put(kItem1Key, MakeUnique<CachedItem>(20));
249 cache.Put(kItem2Key, WrapUnique(new CachedItem(21))); 249 cache.Put(kItem2Key, MakeUnique<CachedItem>(21));
250 cache.Put(kItem3Key, WrapUnique(new CachedItem(22))); 250 cache.Put(kItem3Key, MakeUnique<CachedItem>(22));
251 cache.Put(kItem4Key, WrapUnique(new CachedItem(23))); 251 cache.Put(kItem4Key, MakeUnique<CachedItem>(23));
252 252
253 // The cache should only have kMaxSize items in it even though we inserted 253 // The cache should only have kMaxSize items in it even though we inserted
254 // more. 254 // more.
255 EXPECT_EQ(kMaxSize, cache.size()); 255 EXPECT_EQ(kMaxSize, cache.size());
256 } 256 }
257 257
258 // There should be no objects leaked. 258 // There should be no objects leaked.
259 EXPECT_EQ(initial_count, cached_item_live_count); 259 EXPECT_EQ(initial_count, cached_item_live_count);
260 } 260 }
261 261
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 EXPECT_EQ(item2.value, iter->second.value); 375 EXPECT_EQ(item2.value, iter->second.value);
376 376
377 ++iter; 377 ++iter;
378 ASSERT_TRUE(iter != cache2.end()); 378 ASSERT_TRUE(iter != cache2.end());
379 EXPECT_EQ(kItem1Key, iter->first); 379 EXPECT_EQ(kItem1Key, iter->first);
380 EXPECT_EQ(item1.value, iter->second.value); 380 EXPECT_EQ(item1.value, iter->second.value);
381 } 381 }
382 } 382 }
383 383
384 } // namespace base 384 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/debug/activity_analyzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698