Index: third_party/WebKit/Source/wtf/PassRefPtrTest.cpp |
diff --git a/third_party/WebKit/Source/wtf/PassRefPtrTest.cpp b/third_party/WebKit/Source/wtf/PassRefPtrTest.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..cb6f09c92370806c2b16d285050d8d0f3c6f6700 |
--- /dev/null |
+++ b/third_party/WebKit/Source/wtf/PassRefPtrTest.cpp |
@@ -0,0 +1,26 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "PassRefPtr.h" |
Yuta Kitamura
2016/08/29 05:03:47
nit: We spell out the include path fully; no relat
|
+ |
+#include "testing/gtest/include/gtest/gtest.h" |
+#include "wtf/RefCounted.h" |
+ |
+namespace WTF { |
+ |
+class RefCountedClass : public RefCounted<RefCountedClass> { |
+}; |
+ |
+TEST(PassRefPtrTest, MoveConstructor) |
+{ |
+ PassRefPtr<RefCountedClass> oldPassRefPtr = adoptRef(new RefCountedClass()); |
+ RefCountedClass* rawPtr = oldPassRefPtr.get(); |
+ EXPECT_EQ(rawPtr->refCount(), 1); |
+ PassRefPtr<RefCountedClass> newPassRefPtr = PassRefPtr<RefCountedClass>(std::move(oldPassRefPtr)); |
Yuta Kitamura
2016/08/29 05:03:47
nit: This actually causes a move construction AND
|
+ EXPECT_EQ(oldPassRefPtr.get(), nullptr); |
+ EXPECT_EQ(newPassRefPtr.get(), rawPtr); |
+ EXPECT_EQ(rawPtr->refCount(), 1); |
+} |
+ |
+} // namespace WTF |