| OLD | NEW |
| 1 // Copyright 2015 PDFium Authors. All rights reserved. | 1 // Copyright 2015 PDFium 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 <sstream> | 5 #include <sstream> |
| 6 #include <utility> |
| 6 | 7 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "macros.h" | 9 #include "macros.h" |
| 9 #include "nonstd_unique_ptr.h" | 10 #include "nonstd_unique_ptr.h" |
| 10 | 11 |
| 11 using nonstd::unique_ptr; | 12 using nonstd::unique_ptr; |
| 12 | 13 |
| 13 namespace { | 14 namespace { |
| 14 | 15 |
| 15 // Used to test depth subtyping. | 16 // Used to test depth subtyping. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 } // namespace | 59 } // namespace |
| 59 | 60 |
| 60 TEST(UniquePtrTest, MoveTest) { | 61 TEST(UniquePtrTest, MoveTest) { |
| 61 int constructed = 0; | 62 int constructed = 0; |
| 62 int constructed4 = 0; | 63 int constructed4 = 0; |
| 63 { | 64 { |
| 64 unique_ptr<CtorDtorLogger> ptr1(new CtorDtorLogger(&constructed)); | 65 unique_ptr<CtorDtorLogger> ptr1(new CtorDtorLogger(&constructed)); |
| 65 EXPECT_EQ(1, constructed); | 66 EXPECT_EQ(1, constructed); |
| 66 EXPECT_TRUE(ptr1); | 67 EXPECT_TRUE(ptr1); |
| 67 | 68 |
| 68 unique_ptr<CtorDtorLogger> ptr2(nonstd::move(ptr1)); | 69 unique_ptr<CtorDtorLogger> ptr2(std::move(ptr1)); |
| 69 EXPECT_EQ(1, constructed); | 70 EXPECT_EQ(1, constructed); |
| 70 EXPECT_FALSE(ptr1); | 71 EXPECT_FALSE(ptr1); |
| 71 EXPECT_TRUE(ptr2); | 72 EXPECT_TRUE(ptr2); |
| 72 | 73 |
| 73 unique_ptr<CtorDtorLogger> ptr3; | 74 unique_ptr<CtorDtorLogger> ptr3; |
| 74 ptr3 = nonstd::move(ptr2); | 75 ptr3 = std::move(ptr2); |
| 75 EXPECT_EQ(1, constructed); | 76 EXPECT_EQ(1, constructed); |
| 76 EXPECT_FALSE(ptr2); | 77 EXPECT_FALSE(ptr2); |
| 77 EXPECT_TRUE(ptr3); | 78 EXPECT_TRUE(ptr3); |
| 78 | 79 |
| 79 unique_ptr<CtorDtorLogger> ptr4(new CtorDtorLogger(&constructed4)); | 80 unique_ptr<CtorDtorLogger> ptr4(new CtorDtorLogger(&constructed4)); |
| 80 EXPECT_EQ(1, constructed4); | 81 EXPECT_EQ(1, constructed4); |
| 81 ptr4 = nonstd::move(ptr3); | 82 ptr4 = std::move(ptr3); |
| 82 EXPECT_EQ(0, constructed4); | 83 EXPECT_EQ(0, constructed4); |
| 83 EXPECT_FALSE(ptr3); | 84 EXPECT_FALSE(ptr3); |
| 84 EXPECT_TRUE(ptr4); | 85 EXPECT_TRUE(ptr4); |
| 85 } | 86 } |
| 86 EXPECT_EQ(0, constructed); | 87 EXPECT_EQ(0, constructed); |
| 87 } | 88 } |
| 88 | 89 |
| 89 TEST(UniquePtrTest, UniquePtr) { | 90 TEST(UniquePtrTest, UniquePtr) { |
| 90 int constructed = 0; | 91 int constructed = 0; |
| 91 | 92 |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 TEST(ScopedPtrTest, LoggingDoesntConvertToBoolean) { | 382 TEST(ScopedPtrTest, LoggingDoesntConvertToBoolean) { |
| 382 unique_ptr<int> x(new int); | 383 unique_ptr<int> x(new int); |
| 383 std::stringstream s1; | 384 std::stringstream s1; |
| 384 s1 << x; | 385 s1 << x; |
| 385 | 386 |
| 386 std::stringstream s2; | 387 std::stringstream s2; |
| 387 s2 << x.get(); | 388 s2 << x.get(); |
| 388 | 389 |
| 389 EXPECT_EQ(s2.str(), s1.str()); | 390 EXPECT_EQ(s2.str(), s1.str()); |
| 390 } | 391 } |
| OLD | NEW |