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

Unified Diff: base/containers/scoped_ptr_map_unittest.cc

Issue 1179083006: ScopedPtrMap: Added Compare template parameter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 ef70440f758121ca82601ff0692e74c39351cd4a..1d8f179b0675e759c5a818062d3a62db68da0fd4 100644
--- a/base/containers/scoped_ptr_map_unittest.cc
+++ b/base/containers/scoped_ptr_map_unittest.cc
@@ -4,6 +4,7 @@
#include "base/containers/scoped_ptr_map.h"
+#include <functional>
#include <map>
#include <utility>
@@ -143,6 +144,19 @@ TEST(ScopedPtrMapTest, Clear) {
EXPECT_TRUE(scoped_map.empty());
}
+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)));
+
+ auto it = scoped_map.begin();
+ EXPECT_EQ(1, it->first);
+ ++it;
+ EXPECT_EQ(0, it->first);
+}
+
TEST(ScopedPtrMapTest, Scope) {
bool destroyed = false;
{
« 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