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 <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 } | 315 } |
316 for(LifeCycleWatcher* it = watchers; it != watchers + 1; ++it) | 316 for(LifeCycleWatcher* it = watchers; it != watchers + 1; ++it) |
317 EXPECT_EQ(LC_CONSTRUCTED, it->life_cycle_state()); | 317 EXPECT_EQ(LC_CONSTRUCTED, it->life_cycle_state()); |
318 for(LifeCycleWatcher* it = watchers + 1; it != watchers + 3; ++it) | 318 for(LifeCycleWatcher* it = watchers + 1; it != watchers + 3; ++it) |
319 EXPECT_EQ(LC_DESTROYED, it->life_cycle_state()); | 319 EXPECT_EQ(LC_DESTROYED, it->life_cycle_state()); |
320 for(LifeCycleWatcher* it = watchers + 3; it != watchers + arraysize(watchers); | 320 for(LifeCycleWatcher* it = watchers + 3; it != watchers + arraysize(watchers); |
321 ++it) | 321 ++it) |
322 EXPECT_EQ(LC_CONSTRUCTED, it->life_cycle_state()); | 322 EXPECT_EQ(LC_CONSTRUCTED, it->life_cycle_state()); |
323 } | 323 } |
324 | 324 |
325 // Assertions for push_back(scoped_ptr). | 325 // Assertions for push_back(unique_ptr). |
326 TEST(ScopedVectorTest, PushBackScopedPtr) { | 326 TEST(ScopedVectorTest, PushBackScopedPtr) { |
327 int delete_counter = 0; | 327 int delete_counter = 0; |
328 std::unique_ptr<DeleteCounter> elem(new DeleteCounter(&delete_counter)); | 328 std::unique_ptr<DeleteCounter> elem(new DeleteCounter(&delete_counter)); |
329 EXPECT_EQ(0, delete_counter); | 329 EXPECT_EQ(0, delete_counter); |
330 { | 330 { |
331 ScopedVector<DeleteCounter> v; | 331 ScopedVector<DeleteCounter> v; |
332 v.push_back(std::move(elem)); | 332 v.push_back(std::move(elem)); |
333 EXPECT_EQ(0, delete_counter); | 333 EXPECT_EQ(0, delete_counter); |
334 } | 334 } |
335 EXPECT_EQ(1, delete_counter); | 335 EXPECT_EQ(1, delete_counter); |
336 } | 336 } |
337 | 337 |
338 } // namespace | 338 } // namespace |
OLD | NEW |