OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/memory/scoped_vector.h" | 5 #include "base/memory/scoped_vector.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 } | 301 } |
302 for(LifeCycleWatcher* it = watchers; it != watchers + 1; ++it) | 302 for(LifeCycleWatcher* it = watchers; it != watchers + 1; ++it) |
303 EXPECT_EQ(LC_CONSTRUCTED, it->life_cycle_state()); | 303 EXPECT_EQ(LC_CONSTRUCTED, it->life_cycle_state()); |
304 for(LifeCycleWatcher* it = watchers + 1; it != watchers + 3; ++it) | 304 for(LifeCycleWatcher* it = watchers + 1; it != watchers + 3; ++it) |
305 EXPECT_EQ(LC_DESTROYED, it->life_cycle_state()); | 305 EXPECT_EQ(LC_DESTROYED, it->life_cycle_state()); |
306 for(LifeCycleWatcher* it = watchers + 3; it != watchers + arraysize(watchers); | 306 for(LifeCycleWatcher* it = watchers + 3; it != watchers + arraysize(watchers); |
307 ++it) | 307 ++it) |
308 EXPECT_EQ(LC_CONSTRUCTED, it->life_cycle_state()); | 308 EXPECT_EQ(LC_CONSTRUCTED, it->life_cycle_state()); |
309 } | 309 } |
310 | 310 |
| 311 // Assertions for push_back(scoped_ptr). |
| 312 TEST(ScopedVectorTest, PushBackScopedPtr) { |
| 313 int delete_counter = 0; |
| 314 scoped_ptr<DeleteCounter> elem(new DeleteCounter(&delete_counter)); |
| 315 EXPECT_EQ(0, delete_counter); |
| 316 { |
| 317 ScopedVector<DeleteCounter> v; |
| 318 v.push_back(elem.Pass()); |
| 319 EXPECT_EQ(0, delete_counter); |
| 320 } |
| 321 EXPECT_EQ(1, delete_counter); |
| 322 } |
| 323 |
311 } // namespace | 324 } // namespace |
OLD | NEW |