tst_QVariant: check fromValue() with a non-default-constructible type

... by just using fromValue() instead of the QVariant(QMetaType,
void*) ctor.

Code coverage isn't reduced, because fromValue() will, of course, call
that exact ctor itself.

Amends df0085d3a28005e84eb7688cc2575a121ba322aa.

Pick-to: 6.5 6.4 6.2
Task-number: QTBUG-105140
Task-number: QTBUG-111598
Change-Id: I02464803090fa7078947625616e6fc20e623ef31
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Marc Mutz 2023-03-03 08:17:27 +01:00
parent cbb484b713
commit fd17eaca83

View File

@ -5602,7 +5602,7 @@ void tst_QVariant::constructFromIncompatibleMetaType()
void tst_QVariant::copyNonDefaultConstructible()
{
NonDefaultConstructible ndc(42);
QVariant var(QMetaType::fromType<NonDefaultConstructible>(), &ndc);
QVariant var = QVariant::fromValue(ndc);
QVERIFY(var.isDetached());
QCOMPARE(var.metaType(), QMetaType::fromType<NonDefaultConstructible>());
QVERIFY(var.constData() != &ndc);