| Index: base/memory/scoped_ptr_unittest.cc
|
| diff --git a/base/memory/scoped_ptr_unittest.cc b/base/memory/scoped_ptr_unittest.cc
|
| index 60a050e010e6710fade8b77087dcf45851eb34ed..b26182ad82baa0f0647f4e18646d87714dd5d517 100644
|
| --- a/base/memory/scoped_ptr_unittest.cc
|
| +++ b/base/memory/scoped_ptr_unittest.cc
|
| @@ -84,7 +84,7 @@ int OverloadedNewAndDelete::g_new_count = 0;
|
| int OverloadedNewAndDelete::g_delete_count = 0;
|
|
|
| scoped_ptr<ConDecLogger> PassThru(scoped_ptr<ConDecLogger> logger) {
|
| - return logger.Pass();
|
| + return logger;
|
| }
|
|
|
| void GrabAndDrop(scoped_ptr<ConDecLogger> logger) {
|
| @@ -178,7 +178,7 @@ TEST(ScopedPtrTest, ScopedPtrDepthSubtyping) {
|
| EXPECT_EQ(1, constructed);
|
| EXPECT_TRUE(scoper.get());
|
|
|
| - scoped_ptr<ConDecLoggerParent> scoper_parent(scoper.Pass());
|
| + scoped_ptr<ConDecLoggerParent> scoper_parent(std::move(scoper));
|
| EXPECT_EQ(1, constructed);
|
| EXPECT_TRUE(scoper_parent.get());
|
| EXPECT_FALSE(scoper.get());
|
| @@ -196,7 +196,7 @@ TEST(ScopedPtrTest, ScopedPtrDepthSubtyping) {
|
| EXPECT_TRUE(scoper.get());
|
|
|
| scoped_ptr<ConDecLoggerParent> scoper_parent;
|
| - scoper_parent = scoper.Pass();
|
| + scoper_parent = std::move(scoper);
|
| EXPECT_EQ(1, constructed);
|
| EXPECT_TRUE(scoper_parent.get());
|
| EXPECT_FALSE(scoper.get());
|
| @@ -209,7 +209,7 @@ TEST(ScopedPtrTest, ScopedPtrDepthSubtyping) {
|
| EXPECT_EQ(1, constructed);
|
| EXPECT_TRUE(scoper.get());
|
|
|
| - scoped_ptr<const ConDecLogger> scoper_const(scoper.Pass());
|
| + scoped_ptr<const ConDecLogger> scoper_const(std::move(scoper));
|
| EXPECT_EQ(1, constructed);
|
| EXPECT_TRUE(scoper_const.get());
|
| EXPECT_FALSE(scoper.get());
|
| @@ -227,7 +227,7 @@ TEST(ScopedPtrTest, ScopedPtrDepthSubtyping) {
|
| EXPECT_TRUE(scoper.get());
|
|
|
| scoped_ptr<const ConDecLogger> scoper_const;
|
| - scoper_const = scoper.Pass();
|
| + scoper_const = std::move(scoper);
|
| EXPECT_EQ(1, constructed);
|
| EXPECT_TRUE(scoper_const.get());
|
| EXPECT_FALSE(scoper.get());
|
| @@ -251,7 +251,7 @@ TEST(ScopedPtrTest, ScopedPtrDepthSubtyping) {
|
| EXPECT_EQ(0, alternate_deletes);
|
|
|
| // Test this compiles and correctly overwrites the deleter state.
|
| - scoper = scoper_child.Pass();
|
| + scoper = std::move(scoper_child);
|
| EXPECT_TRUE(scoper);
|
| EXPECT_FALSE(scoper_child);
|
| EXPECT_EQ(1, deletes);
|
| @@ -267,7 +267,8 @@ TEST(ScopedPtrTest, ScopedPtrDepthSubtyping) {
|
| EXPECT_TRUE(scoper_child);
|
| EXPECT_EQ(1, deletes);
|
| EXPECT_EQ(1, alternate_deletes);
|
| - scoped_ptr<double, CountingDeleter> scoper_construct(scoper_child.Pass());
|
| + scoped_ptr<double, CountingDeleter> scoper_construct(
|
| + std::move(scoper_child));
|
| EXPECT_TRUE(scoper_construct);
|
| EXPECT_FALSE(scoper_child);
|
| EXPECT_EQ(1, deletes);
|
| @@ -363,13 +364,13 @@ TEST(ScopedPtrTest, ScopedPtrWithArray) {
|
| }
|
| EXPECT_EQ(kNumLoggers, constructed);
|
|
|
| - // Test Pass() with constructor;
|
| - scoped_ptr<ConDecLogger[]> scoper2(scoper.Pass());
|
| + // Test moving with constructor;
|
| + scoped_ptr<ConDecLogger[]> scoper2(std::move(scoper));
|
| EXPECT_EQ(kNumLoggers, constructed);
|
|
|
| - // Test Pass() with assignment;
|
| + // Test moving with assignment;
|
| scoped_ptr<ConDecLogger[]> scoper3;
|
| - scoper3 = scoper2.Pass();
|
| + scoper3 = std::move(scoper2);
|
| EXPECT_EQ(kNumLoggers, constructed);
|
| EXPECT_FALSE(scoper);
|
| EXPECT_FALSE(scoper2);
|
| @@ -378,27 +379,29 @@ TEST(ScopedPtrTest, ScopedPtrWithArray) {
|
| EXPECT_EQ(0, constructed);
|
| }
|
|
|
| -TEST(ScopedPtrTest, PassBehavior) {
|
| +TEST(ScopedPtrTest, MoveBehavior) {
|
| int constructed = 0;
|
| {
|
| ConDecLogger* logger = new ConDecLogger(&constructed);
|
| scoped_ptr<ConDecLogger> scoper(logger);
|
| EXPECT_EQ(1, constructed);
|
|
|
| - // Test Pass() with constructor;
|
| - scoped_ptr<ConDecLogger> scoper2(scoper.Pass());
|
| + // Test moving with constructor;
|
| + scoped_ptr<ConDecLogger> scoper2(std::move(scoper));
|
| EXPECT_EQ(1, constructed);
|
|
|
| - // Test Pass() with assignment;
|
| + // Test moving with assignment;
|
| scoped_ptr<ConDecLogger> scoper3;
|
| - scoper3 = scoper2.Pass();
|
| + scoper3 = std::move(scoper2);
|
| EXPECT_EQ(1, constructed);
|
| EXPECT_FALSE(scoper.get());
|
| EXPECT_FALSE(scoper2.get());
|
| EXPECT_TRUE(scoper3.get());
|
| }
|
|
|
| - // Test uncaught Pass() does not have side effects.
|
| + // Test uncaught Pass() does not have side effects, because Pass()
|
| + // is implemented by std::move().
|
| + // TODO(danakj): Remove this test case when we remove Pass().
|
| {
|
| ConDecLogger* logger = new ConDecLogger(&constructed);
|
| scoped_ptr<ConDecLogger> scoper(logger);
|
| @@ -419,7 +422,7 @@ TEST(ScopedPtrTest, PassBehavior) {
|
| EXPECT_EQ(1, constructed);
|
|
|
| // Should auto-destruct logger by end of scope.
|
| - GrabAndDrop(scoper.Pass());
|
| + GrabAndDrop(std::move(scoper));
|
| EXPECT_FALSE(scoper.get());
|
| }
|
| EXPECT_EQ(0, constructed);
|
| @@ -434,7 +437,7 @@ TEST(ScopedPtrTest, ReturnTypeBehavior) {
|
| scoped_ptr<ConDecLogger> scoper(logger);
|
| EXPECT_EQ(1, constructed);
|
|
|
| - PassThru(scoper.Pass());
|
| + PassThru(std::move(scoper));
|
| EXPECT_FALSE(scoper.get());
|
| }
|
| EXPECT_EQ(0, constructed);
|
| @@ -446,7 +449,7 @@ TEST(ScopedPtrTest, ReturnTypeBehavior) {
|
| EXPECT_EQ(1, constructed);
|
|
|
| // Should auto-destruct logger by end of scope.
|
| - PassThru(scoper.Pass());
|
| + PassThru(std::move(scoper));
|
| EXPECT_FALSE(scoper.get());
|
| }
|
| EXPECT_EQ(0, constructed);
|
| @@ -537,8 +540,8 @@ TEST(ScopedPtrTest, CustomDeleter) {
|
| // Pass the second deleter through a constructor and an operator=. Then
|
| // reinitialize the empty scopers to ensure that each one is deleting
|
| // properly.
|
| - scoped_ptr<double, CountingDeleter> scoper3(scoper2.Pass());
|
| - scoper = scoper3.Pass();
|
| + scoped_ptr<double, CountingDeleter> scoper3(std::move(scoper2));
|
| + scoper = std::move(scoper3);
|
| EXPECT_EQ(1, deletes);
|
|
|
| scoper2.reset(&dummy_value2);
|
| @@ -575,7 +578,7 @@ TEST(ScopedPtrTest, CustomDeleter) {
|
| }
|
|
|
| // Sanity check test for overloaded new and delete operators. Does not do full
|
| -// coverage of reset/release/Pass() operations as that is redundant with the
|
| +// coverage of reset/release/move operations as that is redundant with the
|
| // above.
|
| TEST(ScopedPtrTest, OverloadedNewAndDelete) {
|
| {
|
| @@ -583,7 +586,7 @@ TEST(ScopedPtrTest, OverloadedNewAndDelete) {
|
| scoped_ptr<OverloadedNewAndDelete> scoper(new OverloadedNewAndDelete());
|
| EXPECT_TRUE(scoper.get());
|
|
|
| - scoped_ptr<OverloadedNewAndDelete> scoper2(scoper.Pass());
|
| + scoped_ptr<OverloadedNewAndDelete> scoper2(std::move(scoper));
|
| }
|
| EXPECT_EQ(1, OverloadedNewAndDelete::delete_count());
|
| EXPECT_EQ(1, OverloadedNewAndDelete::new_count());
|
| @@ -632,9 +635,9 @@ TEST(ScopedPtrTest, Conversion) {
|
| scoped_ptr<Sub> sub1(new Sub);
|
| scoped_ptr<Sub> sub2(new Sub);
|
|
|
| - // Upcast with Pass() works.
|
| - scoped_ptr<Super> super1 = sub1.Pass();
|
| - super1 = sub2.Pass();
|
| + // Upcast with move works.
|
| + scoped_ptr<Super> super1 = std::move(sub1);
|
| + super1 = std::move(sub2);
|
|
|
| // Upcast with an rvalue works.
|
| scoped_ptr<Super> super2 = SubClassReturn();
|
|
|