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

Side by Side Diff: base/id_map_unittest.cc

Issue 609001: Merge 39084 - Correctly recognize emptiness of IDMap.... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/249/src/
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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/id_map.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/id_map.h" 5 #include "base/id_map.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace { 9 namespace {
10 10
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 IDMap<TestObject> map; 52 IDMap<TestObject> map;
53 53
54 TestObject obj1; 54 TestObject obj1;
55 TestObject obj2; 55 TestObject obj2;
56 TestObject obj3; 56 TestObject obj3;
57 57
58 map.Add(&obj1); 58 map.Add(&obj1);
59 map.Add(&obj2); 59 map.Add(&obj2);
60 map.Add(&obj3); 60 map.Add(&obj3);
61 61
62 for (IDMap<TestObject>::const_iterator iter(&map); 62 {
63 !iter.IsAtEnd(); iter.Advance()) { 63 IDMap<TestObject>::const_iterator iter(&map);
64 map.Remove(iter.GetCurrentKey()); 64 while (!iter.IsAtEnd()) {
65 map.Remove(iter.GetCurrentKey());
66 iter.Advance();
67 }
68
69 // Test that while an iterator is still in scope, we get the map emptiness
70 // right (http://crbug.com/35571).
71 EXPECT_TRUE(map.IsEmpty());
72 EXPECT_EQ(0U, map.size());
65 } 73 }
74
75 EXPECT_TRUE(map.IsEmpty());
76 EXPECT_EQ(0U, map.size());
66 } 77 }
67 78
68 TEST_F(IDMapTest, IteratorRemainsValidWhenRemovingOtherElements) { 79 TEST_F(IDMapTest, IteratorRemainsValidWhenRemovingOtherElements) {
69 IDMap<TestObject> map; 80 IDMap<TestObject> map;
70 81
71 const int kCount = 5; 82 const int kCount = 5;
72 TestObject obj[kCount]; 83 TestObject obj[kCount];
73 int32 ids[kCount]; 84 int32 ids[kCount];
74 85
75 for (int i = 0; i < kCount; i++) 86 for (int i = 0; i < kCount; i++)
(...skipping 21 matching lines...) Expand all
97 default: 108 default:
98 FAIL() << "should not have that many elements"; 109 FAIL() << "should not have that many elements";
99 break; 110 break;
100 } 111 }
101 112
102 counter++; 113 counter++;
103 } 114 }
104 } 115 }
105 116
106 } // namespace 117 } // namespace
OLDNEW
« 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