| 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_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 scoped_ptr<ConDecLogger> TestReturnOfType(int* constructed) { | 95 scoped_ptr<ConDecLogger> TestReturnOfType(int* constructed) { |
| 96 return scoped_ptr<ConDecLogger>(new ConDecLogger(constructed)); | 96 return scoped_ptr<ConDecLogger>(new ConDecLogger(constructed)); |
| 97 } | 97 } |
| 98 | 98 |
| 99 } // namespace | 99 } // namespace |
| 100 | 100 |
| 101 TEST(ScopedPtrTest, ScopedPtr) { | 101 TEST(ScopedPtrTest, ScopedPtr) { |
| 102 int constructed = 0; | 102 int constructed = 0; |
| 103 | 103 |
| 104 // Ensure size of scoped_ptr<> doesn't increase unexpectedly. | 104 // Ensure size of scoped_ptr<> doesn't increase unexpectedly. |
| 105 COMPILE_ASSERT(sizeof(int*) >= sizeof(scoped_ptr<int>), | 105 static_assert(sizeof(int*) >= sizeof(scoped_ptr<int>), |
| 106 scoped_ptr_larger_than_raw_ptr); | 106 "scoped_ptr shouldn't be larger than the raw pointer"); |
| 107 | 107 |
| 108 { | 108 { |
| 109 scoped_ptr<ConDecLogger> scoper(new ConDecLogger(&constructed)); | 109 scoped_ptr<ConDecLogger> scoper(new ConDecLogger(&constructed)); |
| 110 EXPECT_EQ(1, constructed); | 110 EXPECT_EQ(1, constructed); |
| 111 EXPECT_TRUE(scoper.get()); | 111 EXPECT_TRUE(scoper.get()); |
| 112 | 112 |
| 113 EXPECT_EQ(10, scoper->SomeMeth(10)); | 113 EXPECT_EQ(10, scoper->SomeMeth(10)); |
| 114 EXPECT_EQ(10, scoper.get()->SomeMeth(10)); | 114 EXPECT_EQ(10, scoper.get()->SomeMeth(10)); |
| 115 EXPECT_EQ(10, (*scoper).SomeMeth(10)); | 115 EXPECT_EQ(10, (*scoper).SomeMeth(10)); |
| 116 } | 116 } |
| (...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 EXPECT_FALSE(p < nullptr); | 825 EXPECT_FALSE(p < nullptr); |
| 826 EXPECT_TRUE(nullptr < p); | 826 EXPECT_TRUE(nullptr < p); |
| 827 EXPECT_FALSE(pnull < nullptr); | 827 EXPECT_FALSE(pnull < nullptr); |
| 828 EXPECT_FALSE(nullptr < pnull); | 828 EXPECT_FALSE(nullptr < pnull); |
| 829 | 829 |
| 830 EXPECT_FALSE(p <= nullptr); | 830 EXPECT_FALSE(p <= nullptr); |
| 831 EXPECT_TRUE(nullptr <= p); | 831 EXPECT_TRUE(nullptr <= p); |
| 832 EXPECT_TRUE(pnull <= nullptr); | 832 EXPECT_TRUE(pnull <= nullptr); |
| 833 EXPECT_TRUE(nullptr <= pnull); | 833 EXPECT_TRUE(nullptr <= pnull); |
| 834 } | 834 } |
| OLD | NEW |