本文整理汇总了C++中Paint::set方法的典型用法代码示例。如果您正苦于以下问题:C++ Paint::set方法的具体用法?C++ Paint::set怎么用?C++ Paint::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Paint
的用法示例。
在下文中一共展示了Paint::set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reset
DEF_TEST(sk_sp, reporter) {
reset_counters();
Paint paint;
REPORTER_ASSERT(reporter, paint.fEffect.get() == nullptr);
REPORTER_ASSERT(reporter, !paint.get());
check(reporter, 0, 0, 0, 0);
paint.set(Create());
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*));
check(reporter, 0, 1, 2, 1);
paint.set(e);
check(reporter, 1, 1, 2, 1);
REPORTER_ASSERT(reporter, paint.fEffect.get()->fRefCnt == 2);
Paint paint2;
paint2.set(paint.get());
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);
check(reporter, 2, 4, 2, 2);
reset_counters();
{
// Test convertible sk_sp assignment.
check(reporter, 0, 0, 0, 0);
sk_sp<Effect> foo(nullptr);
REPORTER_ASSERT(reporter, !foo);
foo = make_effect();
REPORTER_ASSERT(reporter, foo);
check(reporter, 0, 0, 1, 0);
}
check(reporter, 0, 1, 1, 1);
// Test passing convertible rvalue into funtion.
reset_counters();
paint.set(EffectImpl::Create());
check(reporter, 0, 0, 1, 0);
paint.set(nullptr);
check(reporter, 0, 1, 1, 1);
reset_counters();
auto baz = EffectImpl::Create();
check(reporter, 0, 0, 1, 0);
paint.set(std::move(baz));
check(reporter, 0, 0, 1, 0);
REPORTER_ASSERT(reporter, !baz);
paint.set(nullptr);
check(reporter, 0, 1, 1, 1);
reset_counters();
{
// test comparison operator with convertible type.
sk_sp<EffectImpl> bar1 = EffectImpl::Create();
sk_sp<Effect> bar2(bar1); // convertible copy constructor
check(reporter, 1, 0, 1, 0);
REPORTER_ASSERT(reporter, bar1);
REPORTER_ASSERT(reporter, bar2);
REPORTER_ASSERT(reporter, bar1 == bar2);
//.........这里部分代码省略.........