diff options
Diffstat (limited to 'tests/UtilsTest.cpp')
-rw-r--r-- | tests/UtilsTest.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/UtilsTest.cpp b/tests/UtilsTest.cpp index 7f27f7e78e..1c2f870d1f 100644 --- a/tests/UtilsTest.cpp +++ b/tests/UtilsTest.cpp @@ -27,6 +27,35 @@ private: SK_DEFINE_INST_COUNT(RefClass) +static void test_refptr(skiatest::Reporter* reporter) { + RefClass* r0 = new RefClass(0); + + SkRefPtr<RefClass> rc0; + REPORTER_ASSERT(reporter, rc0.get() == NULL); + REPORTER_ASSERT(reporter, !rc0); + + SkRefPtr<RefClass> rc1; + REPORTER_ASSERT(reporter, rc0 == rc1); + REPORTER_ASSERT(reporter, rc0.get() != r0); + + rc0 = r0; + REPORTER_ASSERT(reporter, rc0); + REPORTER_ASSERT(reporter, rc0 != rc1); + REPORTER_ASSERT(reporter, rc0.get() == r0); + + rc1 = rc0; + REPORTER_ASSERT(reporter, rc1); + REPORTER_ASSERT(reporter, rc0 == rc1); + REPORTER_ASSERT(reporter, rc0.get() == r0); + + rc0 = NULL; + REPORTER_ASSERT(reporter, rc0.get() == NULL); + REPORTER_ASSERT(reporter, !rc0); + REPORTER_ASSERT(reporter, rc0 != rc1); + + r0->unref(); +} + static void test_autounref(skiatest::Reporter* reporter) { RefClass obj(0); REPORTER_ASSERT(reporter, 1 == obj.getRefCnt()); @@ -149,6 +178,7 @@ static void TestUTF(skiatest::Reporter* reporter) { test_utf16(reporter); test_search(reporter); + test_refptr(reporter); test_autounref(reporter); } |