tst_QVariant: add a test contrasting Qt 5/6 isNull behavior
A null QString used to make a QVariant containing it null in Qt 5, but this is no longer the case. Add a test that get_if works as expected. Task-number: QTBUG-111598 Change-Id: I0f3511e1b33f4a9d67755269455680feda22ddca Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
a9e8034e8c
commit
690761a4ad
@ -381,6 +381,7 @@ private slots:
|
|||||||
void getIf_int() { getIf_impl(42); }
|
void getIf_int() { getIf_impl(42); }
|
||||||
void getIf_QString() { getIf_impl(u"string"_s); };
|
void getIf_QString() { getIf_impl(u"string"_s); };
|
||||||
void getIf_NonDefaultConstructible();
|
void getIf_NonDefaultConstructible();
|
||||||
|
void getIfSpecial();
|
||||||
|
|
||||||
void get_int() { get_impl(42); }
|
void get_int() { get_impl(42); }
|
||||||
void get_QString() { get_impl(u"string"_s); }
|
void get_QString() { get_impl(u"string"_s); }
|
||||||
@ -5724,6 +5725,12 @@ void tst_QVariant::getIf_NonDefaultConstructible()
|
|||||||
getIf_impl(NonDefaultConstructible{42});
|
getIf_impl(NonDefaultConstructible{42});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QVariant::getIfSpecial()
|
||||||
|
{
|
||||||
|
QVariant v{QString{}}; // used to be a null QVariant in Qt 5
|
||||||
|
QCOMPARE_NE(get_if<QString>(&v), nullptr); // not anymore...
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QVariant::get_NonDefaultConstructible()
|
void tst_QVariant::get_NonDefaultConstructible()
|
||||||
{
|
{
|
||||||
get_impl(NonDefaultConstructible{42});
|
get_impl(NonDefaultConstructible{42});
|
||||||
|
Loading…
Reference in New Issue
Block a user