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

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

Issue 7549003: Optimize phishing page term feature extraction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Brian's comments Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « base/memory/mru_cache.h ('k') | base/string_piece.h » ('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/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/memory/mru_cache.h" 6 #include "base/memory/mru_cache.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace { 9 namespace {
10 10
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 cache.Put(kItem4Key, new CachedItem(23)); 244 cache.Put(kItem4Key, new CachedItem(23));
245 245
246 // The cache should only have kMaxSize items in it even though we inserted 246 // The cache should only have kMaxSize items in it even though we inserted
247 // more. 247 // more.
248 EXPECT_EQ(kMaxSize, cache.size()); 248 EXPECT_EQ(kMaxSize, cache.size());
249 } 249 }
250 250
251 // There should be no objects leaked. 251 // There should be no objects leaked.
252 EXPECT_EQ(initial_count, cached_item_live_count); 252 EXPECT_EQ(initial_count, cached_item_live_count);
253 } 253 }
254
255 TEST(MRUCacheTest, HashingMRUCache) {
256 // Very simple test to make sure that the hashing cache works correctly.
257 typedef base::HashingMRUCache<std::string, CachedItem> Cache;
258 Cache cache(Cache::NO_AUTO_EVICT);
259
260 CachedItem one(1);
261 cache.Put("First", one);
262
263 CachedItem two(2);
264 cache.Put("Second", two);
265
266 EXPECT_EQ(one.value, cache.Get("First")->second.value);
267 EXPECT_EQ(two.value, cache.Get("Second")->second.value);
268 cache.ShrinkToSize(1);
269 EXPECT_EQ(two.value, cache.Get("Second")->second.value);
270 EXPECT_EQ(cache.end(), cache.Get("First"));
271 }
OLDNEW
« no previous file with comments | « base/memory/mru_cache.h ('k') | base/string_piece.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698