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

Unified Diff: Source/wtf/RefPtrTest.cpp

Issue 354143005: Fix RefPtr's move assignment operator (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Stop using std::move Created 6 years, 6 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 | « Source/wtf/RefPtr.h ('k') | Source/wtf/wtf.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/RefPtrTest.cpp
diff --git a/Source/wtf/RefPtrTest.cpp b/Source/wtf/RefPtrTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..29ebedf7a95bfb8f02bd2a3f8d8b0641d7ab9208
--- /dev/null
+++ b/Source/wtf/RefPtrTest.cpp
@@ -0,0 +1,36 @@
+// Copyright 2014 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 "config.h"
+#include "wtf/RefPtr.h"
+
+#include "wtf/text/StringImpl.h"
+#include <gtest/gtest.h>
+
+namespace {
+
+TEST(RefPtrTest, Basic)
+{
+ RefPtr<StringImpl> string;
+ EXPECT_TRUE(!string);
+ string = StringImpl::create("test");
+ EXPECT_TRUE(!!string);
+ string.clear();
+ EXPECT_TRUE(!string);
+}
+
+#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
+TEST(RefPtrTest, MoveAssignmentOperator)
+{
+ RefPtr<StringImpl> a = StringImpl::create("a");
+ RefPtr<StringImpl> b = StringImpl::create("b");
+ // FIXME: Instead of explicitly casting to RefPtr<StringImpl>&& here, we should use std::move, but that
+ // requires us to have a standard library that supports move semantics.
+ b = static_cast<RefPtr<StringImpl>&&>(a);
+ EXPECT_TRUE(!!b);
+ EXPECT_TRUE(!a);
+}
+#endif
+
+}
« no previous file with comments | « Source/wtf/RefPtr.h ('k') | Source/wtf/wtf.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698