Add a test for some copy semantics to QPalette

It isn't a thorough check of all the mutable methods for detaching, but a start.

Change-Id: I523fd30d3459186654e12fd25c384ed990ab7a00
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
This commit is contained in:
Marc Mutz 2014-07-26 21:41:34 +02:00
parent de8a9dee5a
commit 8b75ae4b82

View File

@ -50,6 +50,7 @@ class tst_QPalette : public QObject
private Q_SLOTS:
void roleValues_data();
void roleValues();
void copySemantics();
void moveSemantics();
};
@ -90,6 +91,27 @@ void tst_QPalette::roleValues()
QCOMPARE(role, value);
}
void tst_QPalette::copySemantics()
{
QPalette src(Qt::red), dst;
const QPalette control = src; // copy construction
QVERIFY(src != dst);
QVERIFY(!src.isCopyOf(dst));
QCOMPARE(src, control);
QVERIFY(src.isCopyOf(control));
dst = src; // copy assignment
QCOMPARE(dst, src);
QCOMPARE(dst, control);
QVERIFY(dst.isCopyOf(src));
dst = QPalette(Qt::green);
QVERIFY(dst != src);
QVERIFY(dst != control);
QCOMPARE(src, control);
QVERIFY(!dst.isCopyOf(src));
QVERIFY(src.isCopyOf(control));
}
void tst_QPalette::moveSemantics()
{
#ifdef Q_COMPILER_RVALUE_REFS