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

Unified Diff: base/containers/flat_map_unittest.cc

Issue 2944523002: Improving flat containers interface. (Closed)
Patch Set: Other platforms compilation 2. Created 3 years, 5 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/flat_map.h ('k') | base/containers/flat_set.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/containers/flat_map_unittest.cc
diff --git a/base/containers/flat_map_unittest.cc b/base/containers/flat_map_unittest.cc
index 0556527635a69ebe16153cd33134fdefc8e96fe6..88b3410ac30726bb64b921f0bbf7f864a1c6b416 100644
--- a/base/containers/flat_map_unittest.cc
+++ b/base/containers/flat_map_unittest.cc
@@ -7,8 +7,8 @@
#include <string>
#include <vector>
-#include "base/containers/container_test_utils.h"
#include "base/macros.h"
+#include "base/test/move_only_int.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -170,4 +170,31 @@ TEST(FlatMap, SubscriptMoveOnlyKey) {
EXPECT_EQ(44, m[MoveOnlyInt(1)]);
}
+TEST(FlatMap, UsingTransparentCompare) {
+ using ExplicitInt = base::MoveOnlyInt;
+ base::flat_map<ExplicitInt, int> m;
+ const auto& m1 = m;
+ int x = 0;
+
+ // Check if we can use lookup functions without converting to key_type.
+ // Correctness is checked in flat_tree tests.
+ m.count(x);
+ m1.count(x);
+ m.find(x);
+ m1.find(x);
+ m.equal_range(x);
+ m1.equal_range(x);
+ m.lower_bound(x);
+ m1.lower_bound(x);
+ m.upper_bound(x);
+ m1.upper_bound(x);
+ m.erase(x);
+
+ // Check if we broke overload resolution.
+ m.emplace(ExplicitInt(0), 0);
+ m.emplace(ExplicitInt(1), 0);
+ m.erase(m.begin());
+ m.erase(m.cbegin());
+}
+
} // namespace base
« no previous file with comments | « base/containers/flat_map.h ('k') | base/containers/flat_set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698