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

Unified Diff: base/containers/flat_tree_unittest.cc

Issue 2859593002: base: Add bulk insert to flat_tree. (Closed)
Patch Set: update Created 3 years, 8 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_tree.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/containers/flat_tree_unittest.cc
diff --git a/base/containers/flat_tree_unittest.cc b/base/containers/flat_tree_unittest.cc
index e3a8f879fcf82de71e6951a91c48c7b223d98b96..5ff5fb9c59fa8a920ad75dc5d550ed2553946205 100644
--- a/base/containers/flat_tree_unittest.cc
+++ b/base/containers/flat_tree_unittest.cc
@@ -714,6 +714,49 @@ TEST(FlatTree, InsertPositionLValue) {
// iterator insert(const_iterator position_hint, value_type&& val)
+TEST(FlatTree, BulkInsertLValueIntoEmpty) {
+ IntPairTree cont;
+ IntPair inputs[] = {{1, 1}, {4, 1}, {3, 1}, {0, 1}, {2, 1}, {5, 1}};
+ cont.insert(MakeInputIterator(std::begin(inputs)),
+ MakeInputIterator(std::end(inputs)));
+
+ EXPECT_THAT(cont, ElementsAre(IntPair(0, 1), IntPair(1, 1), IntPair(2, 1),
+ IntPair(3, 1), IntPair(4, 1), IntPair(5, 1)));
+}
+
+TEST(FlatTree, BulkInsertLValueIntoNonEmpty) {
+ IntPair initial_inputs[] = {{1, 0}, {3, 0}, {4, 0}, {6, 0}};
+ IntPairTree cont(MakeInputIterator(std::begin(initial_inputs)),
+ MakeInputIterator(std::end(initial_inputs)),
+ KEEP_FIRST_OF_DUPES);
+
+ IntPair new_inputs[] = {{1, 1}, {0, 1}, {4, 1}, {3, 1},
+ {0, 2}, {2, 1}, {2, 2}, {5, 1}};
+ cont.insert(MakeInputIterator(std::begin(new_inputs)),
+ MakeInputIterator(std::end(new_inputs)));
+
+ EXPECT_THAT(cont, ElementsAre(IntPair(0, 1), IntPair(1, 0), IntPair(2, 1),
+ IntPair(3, 0), IntPair(4, 0), IntPair(5, 1),
+ IntPair(6, 0)));
+}
+
+TEST(FlatTree, BulkInsertRValue) {
+ int initial_inputs[] = {1, 3, 4, 6};
+ MoveOnlyTree cont(std::begin(initial_inputs), std::end(initial_inputs),
+ KEEP_FIRST_OF_DUPES);
+ MoveOnlyInt new_inputs[] = {MoveOnlyInt(0), MoveOnlyInt(1), MoveOnlyInt(5),
+ MoveOnlyInt(4), MoveOnlyInt(3), MoveOnlyInt(2)};
+ cont.insert(std::make_move_iterator(std::begin(new_inputs)),
+ std::make_move_iterator(std::end(new_inputs)));
+ EXPECT_EQ(1U, cont.count(MoveOnlyInt(0)));
+ EXPECT_EQ(1U, cont.count(MoveOnlyInt(1)));
+ EXPECT_EQ(1U, cont.count(MoveOnlyInt(2)));
+ EXPECT_EQ(1U, cont.count(MoveOnlyInt(3)));
+ EXPECT_EQ(1U, cont.count(MoveOnlyInt(4)));
+ EXPECT_EQ(1U, cont.count(MoveOnlyInt(5)));
+ EXPECT_EQ(1U, cont.count(MoveOnlyInt(6)));
+}
+
TEST(FlatTree, InsertPositionRValue) {
MoveOnlyTree cont;
« no previous file with comments | « base/containers/flat_tree.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698