| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 map.Remove(id2); | 47 map.Remove(id2); |
| 48 EXPECT_TRUE(map.IsEmpty()); | 48 EXPECT_TRUE(map.IsEmpty()); |
| 49 EXPECT_EQ(0U, map.size()); | 49 EXPECT_EQ(0U, map.size()); |
| 50 | 50 |
| 51 map.AddWithID(&obj1, 1); | 51 map.AddWithID(&obj1, 1); |
| 52 map.AddWithID(&obj2, 2); | 52 map.AddWithID(&obj2, 2); |
| 53 EXPECT_EQ(&obj1, map.Lookup(1)); | 53 EXPECT_EQ(&obj1, map.Lookup(1)); |
| 54 EXPECT_EQ(&obj2, map.Lookup(2)); | 54 EXPECT_EQ(&obj2, map.Lookup(2)); |
| 55 | 55 |
| 56 EXPECT_EQ(&obj2, map.Replace(2, &obj1)); |
| 57 EXPECT_EQ(&obj1, map.Lookup(2)); |
| 58 |
| 56 EXPECT_EQ(0, map.iteration_depth()); | 59 EXPECT_EQ(0, map.iteration_depth()); |
| 57 } | 60 } |
| 58 | 61 |
| 59 TEST(IDMapTest, IteratorRemainsValidWhenRemovingCurrentElement) { | 62 TEST(IDMapTest, IteratorRemainsValidWhenRemovingCurrentElement) { |
| 60 IDMap<TestObject> map; | 63 IDMap<TestObject> map; |
| 61 | 64 |
| 62 TestObject obj1; | 65 TestObject obj1; |
| 63 TestObject obj2; | 66 TestObject obj2; |
| 64 TestObject obj3; | 67 TestObject obj3; |
| 65 | 68 |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 | 349 |
| 347 for (int i = 0; i < kCount; ++i) { | 350 for (int i = 0; i < kCount; ++i) { |
| 348 delete external_obj[i]; | 351 delete external_obj[i]; |
| 349 } | 352 } |
| 350 | 353 |
| 351 EXPECT_EQ(external_del_count, kCount); | 354 EXPECT_EQ(external_del_count, kCount); |
| 352 EXPECT_EQ(owned_del_count, kCount); | 355 EXPECT_EQ(owned_del_count, kCount); |
| 353 } | 356 } |
| 354 | 357 |
| 355 } // namespace | 358 } // namespace |
| OLD | NEW |