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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 namespace { | 9 namespace { |
10 | 10 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 114 |
115 scoper2.swap(scoper1); | 115 scoper2.swap(scoper1); |
116 EXPECT_EQ(logger, scoper2.get()); | 116 EXPECT_EQ(logger, scoper2.get()); |
117 EXPECT_FALSE(scoper1.get()); | 117 EXPECT_FALSE(scoper1.get()); |
118 EXPECT_FALSE(scoper1 == scoper2.get()); | 118 EXPECT_FALSE(scoper1 == scoper2.get()); |
119 EXPECT_TRUE(scoper1 != scoper2.get()); | 119 EXPECT_TRUE(scoper1 != scoper2.get()); |
120 } | 120 } |
121 EXPECT_EQ(0, constructed); | 121 EXPECT_EQ(0, constructed); |
122 } | 122 } |
123 | 123 |
| 124 TEST(ScopedPtrTest, ScopedPtrArray) { |
| 125 int constructed = 0; |
| 126 |
| 127 { |
| 128 scoped_ptr<int[]> scoper(new int[10]); |
| 129 } |
| 130 EXPECT_EQ(0, constructed); |
| 131 } |
| 132 |
124 TEST(ScopedPtrTest, ScopedPtrDepthSubtyping) { | 133 TEST(ScopedPtrTest, ScopedPtrDepthSubtyping) { |
125 int constructed = 0; | 134 int constructed = 0; |
126 | 135 |
127 // Test construction from a scoped_ptr to a derived class. | 136 // Test construction from a scoped_ptr to a derived class. |
128 { | 137 { |
129 scoped_ptr<ConDecLogger> scoper(new ConDecLogger(&constructed)); | 138 scoped_ptr<ConDecLogger> scoper(new ConDecLogger(&constructed)); |
130 EXPECT_EQ(1, constructed); | 139 EXPECT_EQ(1, constructed); |
131 EXPECT_TRUE(scoper.get()); | 140 EXPECT_TRUE(scoper.get()); |
132 | 141 |
133 scoped_ptr<ConDecLoggerParent> scoper_parent(scoper.Pass()); | 142 scoped_ptr<ConDecLoggerParent> scoper_parent(scoper.Pass()); |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 scoped_ptr<ConDecLoggerParent> scoper_parent; | 359 scoped_ptr<ConDecLoggerParent> scoper_parent; |
351 scoper_parent = UpcastUsingPassAs(scoper.Pass()); | 360 scoper_parent = UpcastUsingPassAs(scoper.Pass()); |
352 EXPECT_EQ(1, constructed); | 361 EXPECT_EQ(1, constructed); |
353 EXPECT_TRUE(scoper_parent.get()); | 362 EXPECT_TRUE(scoper_parent.get()); |
354 EXPECT_FALSE(scoper.get()); | 363 EXPECT_FALSE(scoper.get()); |
355 } | 364 } |
356 EXPECT_EQ(0, constructed); | 365 EXPECT_EQ(0, constructed); |
357 } | 366 } |
358 | 367 |
359 // TODO scoped_ptr_malloc | 368 // TODO scoped_ptr_malloc |
OLD | NEW |