| Index: tests/RefCntTest.cpp
|
| diff --git a/tests/RefCntTest.cpp b/tests/RefCntTest.cpp
|
| index f5345b6a54162354d782bf5466af19f4f1e83e1e..ad3c3a55dba45d5763b6745b12770ce2593388b5 100644
|
| --- a/tests/RefCntTest.cpp
|
| +++ b/tests/RefCntTest.cpp
|
| @@ -272,6 +272,55 @@ DEF_TEST(sk_sp, reporter) {
|
| check(reporter, 1, 1, 1, 0);
|
| paint.set(nullptr);
|
| check(reporter, 1, 2, 1, 1);
|
| +
|
| + {
|
| + sk_sp<SkRefCnt> empty;
|
| + sk_sp<SkRefCnt> notEmpty = sk_make_sp<SkRefCnt>();
|
| + REPORTER_ASSERT(reporter, empty == sk_sp<SkRefCnt>());
|
| +
|
| + REPORTER_ASSERT(reporter, notEmpty != empty);
|
| + REPORTER_ASSERT(reporter, empty != notEmpty);
|
| +
|
| + REPORTER_ASSERT(reporter, nullptr == empty);
|
| + REPORTER_ASSERT(reporter, empty == nullptr);
|
| + REPORTER_ASSERT(reporter, empty == empty);
|
| +
|
| + REPORTER_ASSERT(reporter, nullptr <= empty);
|
| + REPORTER_ASSERT(reporter, empty <= nullptr);
|
| + REPORTER_ASSERT(reporter, empty <= empty);
|
| +
|
| + REPORTER_ASSERT(reporter, nullptr >= empty);
|
| + REPORTER_ASSERT(reporter, empty >= nullptr);
|
| + REPORTER_ASSERT(reporter, empty >= empty);
|
| + }
|
| +
|
| + {
|
| + sk_sp<SkRefCnt> a = sk_make_sp<SkRefCnt>();
|
| + sk_sp<SkRefCnt> b = sk_make_sp<SkRefCnt>();
|
| + REPORTER_ASSERT(reporter, a != b);
|
| + REPORTER_ASSERT(reporter, (a < b) != (b < a));
|
| + REPORTER_ASSERT(reporter, (b > a) != (a > b));
|
| + REPORTER_ASSERT(reporter, (a <= b) != (b <= a));
|
| + REPORTER_ASSERT(reporter, (b >= a) != (a >= b));
|
| +
|
| + REPORTER_ASSERT(reporter, a == a);
|
| + REPORTER_ASSERT(reporter, a <= a);
|
| + REPORTER_ASSERT(reporter, a >= a);
|
| + }
|
| +
|
| + {
|
| + class foo : public SkRefCnt {
|
| + public:
|
| + foo() : bar(this) {}
|
| + void reset() { bar.reset(); }
|
| + private:
|
| + sk_sp<foo> bar;
|
| + };
|
| + // The following should properly delete the object and not cause undefined behavior.
|
| + // This is an ugly example, but the same issue can arise in more subtle ways.
|
| + // http://wg21.cmeerw.net/lwg/issue998
|
| + (new foo)->reset();
|
| + }
|
| }
|
|
|
| namespace {
|
|
|