summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-07-14 12:26:16 +0200
committerLars Knoll <lars.knoll@qt.io>2020-08-24 00:18:24 +0200
commit9d36032370f7b81279ff8774afd7dea4ea57ee6a (patch)
treed750ccd6cd317f056d13495a03fde5881134ec89 /tests/auto/corelib/io
parent2d3b31171d8fce2ab364ca2ceea4e75020933334 (diff)
Implement QMetaType::canConvert() and use it in QVariant
Use the fact that we return the conversion function as a lambda to find out reliably whether a conversion between two types can be done. This requires some minor adjustments to our tests: * Nothing can convert to an unknown type and vice versa * Adjust results to the fact that we don't convert from char to QString anymore (where the old method was incorrect) * QStringList->QString requires some adjustments, as we only convert if the string list has exactly one element. For now we return true in canConvert(), but the conversion behavior in this case is something we should rethink, as it is very surprising. Change-Id: I3f5f87ee9cb99d690f5a7d13b13d6a6313d8038e Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Diffstat (limited to 'tests/auto/corelib/io')
-rw-r--r--tests/auto/corelib/io/qsettings/tst_qsettings.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
index aa893309e8..a84825d1e6 100644
--- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
+++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
@@ -929,7 +929,8 @@ void tst_QSettings::testIniParsing()
if ( settings.status() == QSettings::NoError ) { // else no point proceeding
QVariant v = settings.value(key);
- QVERIFY(v.canConvert(expect.type()));
+ if (expect.isValid())
+ QVERIFY(v.canConvert(expect.type()));
// check some types so as to give prettier error messages
if ( v.type() == QVariant::String ) {
QCOMPARE(v.toString(), expect.toString());