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

Unified Diff: base/containers/small_map_unittest.cc

Issue 130783003: Fix incorrect assumption in IDMap and SmallMap tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: do not use == (causes compile errors) Created 6 years, 11 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 | « no previous file | base/id_map_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/containers/small_map_unittest.cc
diff --git a/base/containers/small_map_unittest.cc b/base/containers/small_map_unittest.cc
index b911bee655dd04e71598648f042811f7353ebe98..bc76e370397b40053db342fa7e84000599a6b2b4 100644
--- a/base/containers/small_map_unittest.cc
+++ b/base/containers/small_map_unittest.cc
@@ -138,30 +138,21 @@ TEST(SmallMap, CopyConstructor) {
}
template<class inner>
-static void SmallMapToMap(SmallMap<inner> const& src, inner* dest) {
+static bool SmallMapIsSubset(SmallMap<inner> const& a,
+ SmallMap<inner> const& b) {
typename SmallMap<inner>::const_iterator it;
- for (it = src.begin(); it != src.end(); ++it) {
- dest->insert(std::make_pair(it->first, it->second));
+ for (it = a.begin(); it != a.end(); ++it) {
+ typename SmallMap<inner>::const_iterator it_in_b = b.find(it->first);
+ if (it_in_b == b.end() || it_in_b->second != it->second)
+ return false;
}
+ return true;
}
template<class inner>
static bool SmallMapEqual(SmallMap<inner> const& a,
SmallMap<inner> const& b) {
- inner ia, ib;
- SmallMapToMap(a, &ia);
- SmallMapToMap(b, &ib);
-
- // On most systems we can use operator== here, but under some lesser STL
- // implementations it doesn't seem to work. So we manually compare.
- if (ia.size() != ib.size())
- return false;
- for (typename inner::iterator ia_it = ia.begin(), ib_it = ib.begin();
- ia_it != ia.end(); ++ia_it, ++ib_it) {
- if (*ia_it != *ib_it)
- return false;
- }
- return true;
+ return SmallMapIsSubset(a, b) && SmallMapIsSubset(b, a);
}
TEST(SmallMap, AssignmentOperator) {
« no previous file with comments | « no previous file | base/id_map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698