Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Unified Diff: third_party/WebKit/Source/wtf/PassRefPtrTest.cpp

Issue 2274793002: Added move constructor to PassRefPtr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed reviewer comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/wtf/PassRefPtr.h ('k') | third_party/WebKit/Source/wtf/wtf.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « third_party/WebKit/Source/wtf/PassRefPtr.h ('k') | third_party/WebKit/Source/wtf/wtf.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698