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

Unified Diff: tests/RefCntTest.cpp

Issue 1760453004: Add operator* and operator safe-bool to sk_sp. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Test all the things. Created 4 years, 10 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 | « include/core/SkRefCnt.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/RefCntTest.cpp
diff --git a/tests/RefCntTest.cpp b/tests/RefCntTest.cpp
index bda45317bcc76abf6915b5a1f7d082ce24f4b5be..60a34ecf886826ecaa972ac612c18ee1d1d8a702 100644
--- a/tests/RefCntTest.cpp
+++ b/tests/RefCntTest.cpp
@@ -164,9 +164,31 @@ DEF_TEST(sk_sp, reporter) {
check(reporter, 0, 0, 1, 0);
REPORTER_ASSERT(reporter, paint.fEffect.get()->fRefCnt == 1);
+ if (paint.get()) {
+ REPORTER_ASSERT(reporter, true);
+ } else {
+ REPORTER_ASSERT(reporter, false);
+ }
+ if (!paint.get()) {
+ REPORTER_ASSERT(reporter, false);
+ } else {
+ REPORTER_ASSERT(reporter, true);
+ }
+
paint.set(nullptr);
check(reporter, 0, 1, 1, 1);
+ if (paint.get()) {
+ REPORTER_ASSERT(reporter, false);
+ } else {
+ REPORTER_ASSERT(reporter, true);
+ }
+ if (!paint.get()) {
+ REPORTER_ASSERT(reporter, true);
+ } else {
+ REPORTER_ASSERT(reporter, false);
+ }
+
auto e = Create();
REPORTER_ASSERT(reporter, sizeof(e) == sizeof(void*));
@@ -180,9 +202,14 @@ DEF_TEST(sk_sp, reporter) {
check(reporter, 2, 1, 2, 1);
REPORTER_ASSERT(reporter, paint.fEffect.get()->fRefCnt == 3);
+ // Test sk_sp::operator->
delete paint.get()->method();
check(reporter, 2, 1, 2, 1);
+ // Test sk_sp::operator*
+ delete (*paint.get()).method();
+ check(reporter, 2, 1, 2, 1);
+
paint.set(nullptr);
e = nullptr;
paint2.set(nullptr);
« no previous file with comments | « include/core/SkRefCnt.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698