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

Unified Diff: base/stl_util_unittest.cc

Issue 11415239: Add STLSetDifference to stl_util.h, because std::set_difference is extremely (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add tests Created 8 years, 1 month 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/stl_util.h ('K') | « base/stl_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/stl_util_unittest.cc
diff --git a/base/stl_util_unittest.cc b/base/stl_util_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ca23617dea28aa891772c8a85032308c186cfa0b
--- /dev/null
+++ b/base/stl_util_unittest.cc
@@ -0,0 +1,57 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <set>
+
+#include "base/stl_util.h"
willchan no longer on Chromium 2012/12/01 17:22:13 This should go first
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+TEST(STLUtilTest, STLSetDifference) {
+ std::set<int> a1;
+ a1.insert(1);
+ a1.insert(2);
+ a1.insert(3);
+ a1.insert(4);
+
+ std::set<int> a2;
+ a2.insert(3);
+ a2.insert(4);
+ a2.insert(5);
+ a2.insert(6);
+ a2.insert(7);
+
+ {
+ std::set<int> difference;
+ difference.insert(1);
+ difference.insert(2);
+ EXPECT_EQ(difference, STLSetDifference<std::set<int> >(a1, a2));
+ }
+
+ {
+ std::set<int> difference;
+ difference.insert(5);
+ difference.insert(6);
+ difference.insert(7);
+ EXPECT_EQ(difference, STLSetDifference<std::set<int> >(a2, a1));
+ }
+
+ {
+ std::vector<int> difference;
+ difference.push_back(1);
+ difference.push_back(2);
+ EXPECT_EQ(difference, STLSetDifference<std::vector<int> >(a1, a2));
+ }
+
+ {
+ std::vector<int> difference;
+ difference.push_back(5);
+ difference.push_back(6);
+ difference.push_back(7);
+ EXPECT_EQ(difference, STLSetDifference<std::vector<int> >(a2, a1));
+ }
+}
+
+} // namespace
« base/stl_util.h ('K') | « base/stl_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698