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

Unified Diff: base/containers/flat_tree_unittest.cc

Issue 2807933002: Removing (dest != prev) check from LastUnique algorithm. (Closed)
Patch Set: 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
« base/containers/flat_tree.h ('K') | « 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..3cbd4926346b93effd7b4983add8865430f516ac 100644
--- a/base/containers/flat_tree_unittest.cc
+++ b/base/containers/flat_tree_unittest.cc
@@ -170,68 +170,6 @@ using ::testing::ElementsAre;
} // namespace
-TEST(FlatTree, LastUnique) {
dyaroshev 2017/04/08 16:48:03 @brettew - I haven't seen these tests. I like my t
- using Pair = std::pair<int, int>;
- using Vect = std::vector<Pair>;
-
- auto cmp = [](const Pair& lhs, const Pair& rhs) {
- return lhs.first == rhs.first;
- };
-
- // Empty case.
- Vect empty;
- EXPECT_EQ(empty.end(), LastUnique(empty.begin(), empty.end(), cmp));
-
- // Single element.
- Vect one;
- one.push_back(Pair(1, 1));
- EXPECT_EQ(one.end(), LastUnique(one.begin(), one.end(), cmp));
- ASSERT_EQ(1u, one.size());
- EXPECT_THAT(one, ElementsAre(Pair(1, 1)));
-
- // Two elements, already unique.
- Vect two_u;
- two_u.push_back(Pair(1, 1));
- two_u.push_back(Pair(2, 2));
- EXPECT_EQ(two_u.end(), LastUnique(two_u.begin(), two_u.end(), cmp));
- EXPECT_THAT(two_u, ElementsAre(Pair(1, 1), Pair(2, 2)));
-
- // Two elements, dupes.
- Vect two_d;
- two_d.push_back(Pair(1, 1));
- two_d.push_back(Pair(1, 2));
- auto last = LastUnique(two_d.begin(), two_d.end(), cmp);
- EXPECT_EQ(two_d.begin() + 1, last);
- two_d.erase(last, two_d.end());
- EXPECT_THAT(two_d, ElementsAre(Pair(1, 2)));
-
- // Non-dupes, dupes, non-dupes.
- Vect ndn;
- ndn.push_back(Pair(1, 1));
- ndn.push_back(Pair(2, 1));
- ndn.push_back(Pair(2, 2));
- ndn.push_back(Pair(2, 3));
- ndn.push_back(Pair(3, 1));
- last = LastUnique(ndn.begin(), ndn.end(), cmp);
- EXPECT_EQ(ndn.begin() + 3, last);
- ndn.erase(last, ndn.end());
- EXPECT_THAT(ndn, ElementsAre(Pair(1, 1), Pair(2, 3), Pair(3, 1)));
-
- // Dupes, non-dupes, dupes.
- Vect dnd;
- dnd.push_back(Pair(1, 1));
- dnd.push_back(Pair(1, 2));
- dnd.push_back(Pair(1, 3));
- dnd.push_back(Pair(2, 1));
- dnd.push_back(Pair(3, 1));
- dnd.push_back(Pair(3, 2));
- dnd.push_back(Pair(3, 3));
- last = LastUnique(dnd.begin(), dnd.end(), cmp);
- EXPECT_EQ(dnd.begin() + 3, last);
- dnd.erase(last, dnd.end());
- EXPECT_THAT(dnd, ElementsAre(Pair(1, 3), Pair(2, 1), Pair(3, 3)));
-}
-
// ----------------------------------------------------------------------------
// Class.
« base/containers/flat_tree.h ('K') | « base/containers/flat_tree.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698