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..669a925021be974a7a72c12136e9f0fcca6a2675 100644 |
--- a/base/containers/flat_tree_unittest.cc |
+++ b/base/containers/flat_tree_unittest.cc |
@@ -31,8 +31,6 @@ |
// this. |
// * No tests with min_allocator and no tests counting allocations. |
// Flat sets currently don't support allocators. |
-// * No tests for range insertion. Flat sets currently do not support this |
-// functionality. |
#include <string> |
#include <vector> |
@@ -738,6 +736,42 @@ TEST(FlatTree, InsertPositionRValue) { |
EXPECT_EQ(3, result->data()); |
} |
+// template <class InputIterator> |
+// void insert(InputIterator first, InputIterator last); |
+ |
+TEST(FlatTree, InsertIterIter) { |
+ struct GetKeyFromIntIntPair { |
+ int operator()(const std::pair<int, int>& p) const { return p.first; } |
+ }; |
+ |
+ using IntIntMap = |
+ flat_tree<int, IntPair, GetKeyFromIntIntPair, std::less<int>>; |
+ IntIntMap cont; |
+ |
+ { |
+ IntPair int_pairs[] = {{3, 1}, {1, 1}, {4, 1}, {2, 1}}; |
+ cont.insert(std::begin(int_pairs), std::end(int_pairs)); |
+ EXPECT_THAT(cont, ElementsAre(IntPair(1, 1), IntPair(2, 1), IntPair(3, 1), |
+ IntPair(4, 1))); |
+ } |
+ |
+ { |
+ IntPair int_pairs[] = {{3, 2}, {1, 2}, {4, 2}, {2, 2}}; |
+ cont.insert(std::begin(int_pairs), std::end(int_pairs)); |
+ EXPECT_THAT(cont, ElementsAre(IntPair(1, 1), IntPair(2, 1), IntPair(3, 1), |
+ IntPair(4, 1))); |
+ } |
+ |
+ { |
+ IntPair int_pairs[] = {{3, 2}, {1, 2}, {4, 2}, {2, 2}, {7, 2}, {6, 2}, |
+ {8, 2}, {5, 2}, {5, 3}, {6, 3}, {7, 3}, {8, 3}}; |
+ cont.insert(std::begin(int_pairs), std::end(int_pairs)); |
+ EXPECT_THAT(cont, ElementsAre(IntPair(1, 1), IntPair(2, 1), IntPair(3, 1), |
+ IntPair(4, 1), IntPair(5, 2), IntPair(6, 2), |
+ IntPair(7, 2), IntPair(8, 2))); |
+ } |
dyaroshev
2017/05/09 09:32:46
An empty range check is important.
Maybe we want
jdoerrie
2017/05/09 17:03:30
Done.
|
+} |
+ |
// template <class... Args> |
// pair<iterator, bool> emplace(Args&&... args) |