diff options
Diffstat (limited to 'Tools/TestWebKitAPI/Tests/WTF/Ref.cpp')
-rw-r--r-- | Tools/TestWebKitAPI/Tests/WTF/Ref.cpp | 57 |
1 files changed, 21 insertions, 36 deletions
diff --git a/Tools/TestWebKitAPI/Tests/WTF/Ref.cpp b/Tools/TestWebKitAPI/Tests/WTF/Ref.cpp index 8c622d07b..1b9eef67a 100644 --- a/Tools/TestWebKitAPI/Tests/WTF/Ref.cpp +++ b/Tools/TestWebKitAPI/Tests/WTF/Ref.cpp @@ -26,6 +26,7 @@ #include "config.h" #include "RefLogger.h" +#include <wtf/PassRef.h> #include <wtf/Ref.h> #include <wtf/RefPtr.h> @@ -37,14 +38,14 @@ TEST(WTF_Ref, Basic) { Ref<RefLogger> ptr(a); - ASSERT_EQ(&a, ptr.ptr()); + ASSERT_EQ(&a, &ptr.get()); ASSERT_EQ(&a.name, &ptr->name); } ASSERT_STREQ("ref(a) deref(a) ", takeLogStr().c_str()); { Ref<RefLogger> ptr(adoptRef(a)); - ASSERT_EQ(&a, ptr.ptr()); + ASSERT_EQ(&a, &ptr.get()); ASSERT_EQ(&a.name, &ptr->name); } ASSERT_STREQ("deref(a) ", takeLogStr().c_str()); @@ -58,51 +59,51 @@ TEST(WTF_Ref, Assignment) { Ref<RefLogger> ptr(a); - ASSERT_EQ(&a, ptr.ptr()); + ASSERT_EQ(&a, &ptr.get()); log() << "| "; ptr = b; - ASSERT_EQ(&b, ptr.ptr()); + ASSERT_EQ(&b, &ptr.get()); log() << "| "; } ASSERT_STREQ("ref(a) | ref(b) deref(a) | deref(b) ", takeLogStr().c_str()); { Ref<RefLogger> ptr(a); - ASSERT_EQ(&a, ptr.ptr()); + ASSERT_EQ(&a, &ptr.get()); log() << "| "; ptr = c; - ASSERT_EQ(&c, ptr.ptr()); + ASSERT_EQ(&c, &ptr.get()); log() << "| "; } ASSERT_STREQ("ref(a) | ref(c) deref(a) | deref(c) ", takeLogStr().c_str()); { Ref<RefLogger> ptr(a); - ASSERT_EQ(&a, ptr.ptr()); + ASSERT_EQ(&a, &ptr.get()); log() << "| "; ptr = adoptRef(b); - ASSERT_EQ(&b, ptr.ptr()); + ASSERT_EQ(&b, &ptr.get()); log() << "| "; } ASSERT_STREQ("ref(a) | deref(a) | deref(b) ", takeLogStr().c_str()); { Ref<RefLogger> ptr(a); - ASSERT_EQ(&a, ptr.ptr()); + ASSERT_EQ(&a, &ptr.get()); log() << "| "; ptr = adoptRef(c); - ASSERT_EQ(&c, ptr.ptr()); + ASSERT_EQ(&c, &ptr.get()); log() << "| "; } ASSERT_STREQ("ref(a) | deref(a) | deref(c) ", takeLogStr().c_str()); } -static Ref<RefLogger> passWithRef(Ref<RefLogger>&& reference) +PassRef<RefLogger> passWithPassRef(PassRef<RefLogger> reference) { - return WTF::move(reference); + return reference; } -static RefPtr<RefLogger> passWithPassRefPtr(PassRefPtr<RefLogger> reference) +RefPtr<RefLogger> passWithPassRefPtr(PassRefPtr<RefLogger> reference) { return reference; } @@ -114,48 +115,32 @@ TEST(WTF_Ref, ReturnValue) DerivedRefLogger c("c"); { - Ref<RefLogger> ptr(passWithRef(Ref<RefLogger>(a))); - ASSERT_EQ(&a, ptr.ptr()); + Ref<RefLogger> ptr(passWithPassRef(a)); + ASSERT_EQ(&a, &ptr.get()); } ASSERT_STREQ("ref(a) deref(a) ", takeLogStr().c_str()); { Ref<RefLogger> ptr(a); - ASSERT_EQ(&a, ptr.ptr()); + ASSERT_EQ(&a, &ptr.get()); log() << "| "; - ptr = passWithRef(b); - ASSERT_EQ(&b, ptr.ptr()); + ptr = passWithPassRef(b); + ASSERT_EQ(&b, &ptr.get()); log() << "| "; } ASSERT_STREQ("ref(a) | ref(b) deref(a) | deref(b) ", takeLogStr().c_str()); { - RefPtr<RefLogger> ptr(passWithRef(a)); + RefPtr<RefLogger> ptr(passWithPassRef(a)); ASSERT_EQ(&a, ptr.get()); } ASSERT_STREQ("ref(a) deref(a) ", takeLogStr().c_str()); { - RefPtr<RefLogger> ptr(passWithPassRefPtr(passWithRef(a))); + RefPtr<RefLogger> ptr(passWithPassRefPtr(passWithPassRef(a))); ASSERT_EQ(&a, ptr.get()); } ASSERT_STREQ("ref(a) deref(a) ", takeLogStr().c_str()); - - { - RefPtr<DerivedRefLogger> ptr(&a); - RefPtr<RefLogger> ptr2(WTF::move(ptr)); - ASSERT_EQ(nullptr, ptr.get()); - ASSERT_EQ(&a, ptr2.get()); - } - ASSERT_STREQ("ref(a) deref(a) ", takeLogStr().c_str()); - - { - Ref<DerivedRefLogger> derivedReference(a); - Ref<RefLogger> baseReference(passWithRef(derivedReference.copyRef())); - ASSERT_EQ(&a, derivedReference.ptr()); - ASSERT_EQ(&a, baseReference.ptr()); - } - ASSERT_STREQ("ref(a) ref(a) deref(a) deref(a) ", takeLogStr().c_str()); } } // namespace TestWebKitAPI |