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

Unified Diff: base/id_map_unittest.cc

Issue 604048: Correctly recognize emptiness of IDMap. (Closed)
Patch Set: Created 10 years, 10 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/id_map.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/id_map_unittest.cc
diff --git a/base/id_map_unittest.cc b/base/id_map_unittest.cc
index 58abf9605ed46393e2fc18cc9393c3fc347df71d..54475b678919c968a2dca5db28170711d7ef7ac4 100644
--- a/base/id_map_unittest.cc
+++ b/base/id_map_unittest.cc
@@ -67,10 +67,21 @@ TEST_F(IDMapTest, IteratorRemainsValidWhenRemovingCurrentElement) {
map.Add(&obj2);
map.Add(&obj3);
- for (IDMap<TestObject>::const_iterator iter(&map);
- !iter.IsAtEnd(); iter.Advance()) {
- map.Remove(iter.GetCurrentKey());
+ {
+ IDMap<TestObject>::const_iterator iter(&map);
+ while (!iter.IsAtEnd()) {
+ map.Remove(iter.GetCurrentKey());
+ iter.Advance();
+ }
+
+ // Test that while an iterator is still in scope, we get the map emptiness
+ // right (http://crbug.com/35571).
+ EXPECT_TRUE(map.IsEmpty());
+ EXPECT_EQ(0U, map.size());
}
+
+ EXPECT_TRUE(map.IsEmpty());
+ EXPECT_EQ(0U, map.size());
}
TEST_F(IDMapTest, IteratorRemainsValidWhenRemovingOtherElements) {
« no previous file with comments | « base/id_map.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698