Rearrange tst_QSettings::testVariantTypes()

Move the large block unrelated to the macro-driven parts to before the
macro is defined. This makes it clearer that it has nothing to do with
the macro-driven part of the test. This is, in any case, a more basic
test of behavior, so may as well go first. Rename the tested key in
the process.

Change-Id: I783fcd812e36320e9bb9765bab3ec09b56d6e6e6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Edward Welbourne 2022-04-20 14:39:22 +02:00
parent cfc2973eec
commit af61bb018f

View File

@ -1276,6 +1276,30 @@ FOR_EACH_CORE_METATYPE(RETURN_CREATE_FUNCTION)
#ifdef QT_BUILD_INTERNAL
void tst_QSettings::testVariantTypes()
{
QFETCH(QSettings::Format, format);
{
QSettings settings(format, QSettings::UserScope, "software.org", "KillerAPP");
QVERIFY(!settings.contains("empty"));
QCOMPARE(settings.value("empty"), QVariant());
settings.setValue("empty", QVariant());
QVERIFY(settings.contains("empty"));
QCOMPARE(settings.value("empty"), QVariant());
settings.setValue("empty", QVariant(1));
QVERIFY(settings.contains("empty"));
QCOMPARE(settings.value("empty"), QVariant(1));
settings.setValue("empty", QVariant());
QVERIFY(settings.contains("empty"));
QCOMPARE(settings.value("empty"), QVariant());
settings.remove("empty");
QVERIFY(!settings.contains("empty"));
QCOMPARE(settings.value("empty"), QVariant());
}
#define testVal(key, val, tp, rtype) \
{ \
QSettings settings1(format, QSettings::UserScope, "software.org", "KillerAPP"); \
@ -1291,8 +1315,6 @@ void tst_QSettings::testVariantTypes()
typedef QMap<QString, QVariant> TestVariantMap;
QFETCH(QSettings::Format, format);
TestVariantMap m2;
m2.insert("ene", "due");
m2.insert("rike", "fake");
@ -1324,28 +1346,6 @@ void tst_QSettings::testVariantTypes()
testVal("key11", time, QTime, Time);
testVal("key12", QByteArray("foo bar"), QByteArray, ByteArray);
{
QSettings settings(format, QSettings::UserScope, "software.org", "KillerAPP");
QVERIFY(!settings.contains("key99"));
QCOMPARE(settings.value("key99"), QVariant());
settings.setValue("key99", QVariant());
QVERIFY(settings.contains("key99"));
QCOMPARE(settings.value("key99"), QVariant());
settings.setValue("key99", QVariant(1));
QVERIFY(settings.contains("key99"));
QCOMPARE(settings.value("key99"), QVariant(1));
settings.setValue("key99", QVariant());
QVERIFY(settings.contains("key99"));
QCOMPARE(settings.value("key99"), QVariant());
settings.remove("key99");
QVERIFY(!settings.contains("key99"));
QCOMPARE(settings.value("key99"), QVariant());
}
QList<QVariant> l4;
l4 << QVariant(m2) << QVariant(l2) << QVariant(l3);
testVal("key13", l4, QVariantList, List);