Index: base/memory/scoped_ptr_unittest.cc |
diff --git a/base/memory/scoped_ptr_unittest.cc b/base/memory/scoped_ptr_unittest.cc |
index ea135333eaef4cd820dfc4f7844522a420d3358e..63125dbf49bb6f349d5e3231d582141e061fe19d 100644 |
--- a/base/memory/scoped_ptr_unittest.cc |
+++ b/base/memory/scoped_ptr_unittest.cc |
@@ -45,6 +45,11 @@ scoped_ptr<ConDecLogger> TestReturnOfType(int* constructed) { |
return scoped_ptr<ConDecLogger>(new ConDecLogger(constructed)); |
} |
+scoped_ptr<ConDecLoggerParent> UpcastUsingPassAs( |
+ scoped_ptr<ConDecLogger> object) { |
+ return object.PassAs<ConDecLoggerParent>(); |
+} |
+ |
} // namespace |
TEST(ScopedPtrTest, ScopedPtr) { |
@@ -333,4 +338,20 @@ TEST(ScopedPtrTest, ReturnTypeBehavior) { |
EXPECT_EQ(0, constructed); |
} |
+TEST(ScopedPtrTest, PassAs) { |
+ int constructed = 0; |
+ { |
+ scoped_ptr<ConDecLogger> scoper(new ConDecLogger(&constructed)); |
+ EXPECT_EQ(1, constructed); |
+ EXPECT_TRUE(scoper.get()); |
+ |
+ scoped_ptr<ConDecLoggerParent> scoper_parent; |
+ scoper_parent = UpcastUsingPassAs(scoper.Pass()); |
+ EXPECT_EQ(1, constructed); |
+ EXPECT_TRUE(scoper_parent.get()); |
+ EXPECT_FALSE(scoper.get()); |
+ } |
+ EXPECT_EQ(0, constructed); |
+} |
+ |
// TODO scoped_ptr_malloc |