diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/gui/kernel/qpalette/tst_qpalette.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp index da6f3a548b..b2c0ff979c 100644 --- a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp +++ b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp @@ -50,6 +50,7 @@ class tst_QPalette : public QObject private Q_SLOTS: void roleValues_data(); void roleValues(); + void moveSemantics(); }; void tst_QPalette::roleValues_data() @@ -89,5 +90,26 @@ void tst_QPalette::roleValues() QCOMPARE(role, value); } +void tst_QPalette::moveSemantics() +{ +#ifdef Q_COMPILER_RVALUE_REFS + QPalette src(Qt::red), dst; + const QPalette control = src; + QVERIFY(src != dst); + QCOMPARE(src, control); + QVERIFY(!dst.isCopyOf(src)); + QVERIFY(!dst.isCopyOf(control)); + dst = qMove(src); // move assignment + QVERIFY(!dst.isCopyOf(src)); // isCopyOf() works on moved-from palettes, too + QVERIFY(dst.isCopyOf(control)); + QCOMPARE(dst, control); + src = control; // check moved-from 'src' can still be assigned to (doesn't crash) + QVERIFY(src.isCopyOf(dst)); + QVERIFY(src.isCopyOf(control)); +#else + QSKIP("Compiler doesn't support C++11 move semantics"); +#endif +} + QTEST_MAIN(tst_QPalette) #include "tst_qpalette.moc" |