summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2014-07-25 23:15:24 +0200
committerMarc Mutz <marc.mutz@kdab.com>2014-07-31 21:04:43 +0200
commitb88d4b038461ff3d43add85ae86fbf3d6d7afe45 (patch)
treef1df4fca8133a6f1efa5dcc5cecb77ac4ba1a4c1 /tests/auto/gui
parentd8dc664b945d8832eab97c5df0e1ea47ebf895fd (diff)
Add a test for move assignment to tst_QPalette
It was simply missing. Change-Id: I6645bb9fe9c81aec9c46ac5efc7d2295a3784ff6 Reviewed-by: J-P Nurmi <jpnurmi@digia.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r--tests/auto/gui/kernel/qpalette/tst_qpalette.cpp22
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"