diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-16 09:15:38 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-16 09:15:38 +0000 |
commit | 2de069ee4f16b2b5f89c0c435c0ca3788e317d5c (patch) | |
tree | 919a1bca247f2a2cc5e4ab9acafdfe37154edb16 /base/id_map_unittest.cc | |
parent | 9beaf2987dfc53dc150ac8c22336ea5046da005c (diff) | |
download | chromium_src-2de069ee4f16b2b5f89c0c435c0ca3788e317d5c.zip chromium_src-2de069ee4f16b2b5f89c0c435c0ca3788e317d5c.tar.gz chromium_src-2de069ee4f16b2b5f89c0c435c0ca3788e317d5c.tar.bz2 |
Correctly recognize emptiness of IDMap.
This prevents a leak of RenderProcessHost, and possibly other
bad bugs.
TEST=Added to base_unittests; also existing browser and unit tests.
BUG=35571
Review URL: http://codereview.chromium.org/604048
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39084 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/id_map_unittest.cc')
-rw-r--r-- | base/id_map_unittest.cc | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/base/id_map_unittest.cc b/base/id_map_unittest.cc index 58abf96..54475b6 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) { |