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

Unified Diff: base/containers/flat_set_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_set.h ('k') | base/containers/flat_tree.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/containers/flat_set_unittest.cc
diff --git a/base/containers/flat_set_unittest.cc b/base/containers/flat_set_unittest.cc
index dc024fcf0a9729a15d4987e3980da46306a6b143..45969754985082685aa4e7b63239c2d962f3bb8f 100644
--- a/base/containers/flat_set_unittest.cc
+++ b/base/containers/flat_set_unittest.cc
@@ -7,8 +7,9 @@
#include <string>
#include <vector>
-#include "base/containers/container_test_utils.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
+#include "base/test/move_only_int.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -90,4 +91,31 @@ TEST(FlatSet, CopySwap) {
EXPECT_THAT(copy, ElementsAre(1, 2));
}
+TEST(FlatSet, UsingTransparentCompare) {
+ using ExplicitInt = base::MoveOnlyInt;
+ base::flat_set<ExplicitInt> s;
+ const auto& s1 = s;
+ int x = 0;
+
+ // Check if we can use lookup functions without converting to key_type.
+ // Correctness is checked in flat_tree tests.
+ s.count(x);
+ s1.count(x);
+ s.find(x);
+ s1.find(x);
+ s.equal_range(x);
+ s1.equal_range(x);
+ s.lower_bound(x);
+ s1.lower_bound(x);
+ s.upper_bound(x);
+ s1.upper_bound(x);
+ s.erase(x);
+
+ // Check if we broke overload resolution.
+ s.emplace(0);
+ s.emplace(1);
+ s.erase(s.begin());
+ s.erase(s.cbegin());
+}
+
} // namespace base
« no previous file with comments | « base/containers/flat_set.h ('k') | base/containers/flat_tree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698