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

Unified Diff: base/containers/scoped_ptr_map_unittest.cc

Issue 1328203002: Fix ScopedPtrMap with custom Compare. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added unit tests. Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/containers/scoped_ptr_map.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/containers/scoped_ptr_map_unittest.cc
diff --git a/base/containers/scoped_ptr_map_unittest.cc b/base/containers/scoped_ptr_map_unittest.cc
index 46843b3f2529f288ec3ef9cdef1884608cfa2524..706b2edfb188b264073989b1d06ce5d79a291dd5 100644
--- a/base/containers/scoped_ptr_map_unittest.cc
+++ b/base/containers/scoped_ptr_map_unittest.cc
@@ -147,15 +147,30 @@ TEST(ScopedPtrMapTest, Clear) {
TEST(ScopedPtrMapTest, Compare) {
// Construct a ScopedPtrMap with a custom comparison function.
- bool destroyed = false;
- ScopedPtrMap<int, scoped_ptr<ScopedDestroyer>, std::greater<int>> scoped_map;
- scoped_map.insert(0, make_scoped_ptr(new ScopedDestroyer(&destroyed)));
- scoped_map.insert(1, make_scoped_ptr(new ScopedDestroyer(&destroyed)));
+ ScopedPtrMap<int, scoped_ptr<int>, std::greater<int>> scoped_map1;
+ scoped_map1.insert(0, make_scoped_ptr(new int(0)));
+ scoped_map1.insert(1, make_scoped_ptr(new int(0)));
- auto it = scoped_map.begin();
+ auto it = scoped_map1.begin();
EXPECT_EQ(1, it->first);
++it;
EXPECT_EQ(0, it->first);
+
+ // Test the move constructor.
+ ScopedPtrMap<int, scoped_ptr<int>, std::greater<int>> scoped_map2(
+ scoped_map1.Pass());
+ EXPECT_EQ(2u, scoped_map2.size());
+ EXPECT_TRUE(scoped_map1.empty());
+
+ // Test move assignment.
+ scoped_map1 = scoped_map2.Pass();
+ EXPECT_EQ(2u, scoped_map1.size());
+ EXPECT_TRUE(scoped_map2.empty());
+
+ // Test swap.
+ scoped_map2.swap(scoped_map1);
+ EXPECT_EQ(2u, scoped_map2.size());
+ EXPECT_TRUE(scoped_map1.empty());
}
TEST(ScopedPtrMapTest, Scope) {
« no previous file with comments | « base/containers/scoped_ptr_map.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698