Inline a shared data-driven test table in tst_QSettings

Move its static populateWithFormats to before the class is declared
and make the _data() methods that call it (including one that did so
via another) inline so that we can see which are this simple - and
thus which aren't.

Change-Id: I71863244ba0e4bd188424b6a3f8d86d5d9f635a9
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 11:44:40 +02:00
parent a7138c4fd1
commit b0d55004b8

View File

@ -103,6 +103,16 @@ static inline bool canWriteNativeSystemSettings()
static const char insufficientPermissionSkipMessage[] = "Insufficient permissions for this test.";
static void populateWithFormats()
{
QTest::addColumn<QSettings::Format>("format");
QTest::newRow("native") << QSettings::NativeFormat;
QTest::newRow("ini") << QSettings::IniFormat;
QTest::newRow("custom1") << QSettings::CustomFormat1;
QTest::newRow("custom2") << QSettings::CustomFormat2;
}
class tst_QSettings : public QObject
{
Q_OBJECT
@ -115,7 +125,7 @@ public slots:
void cleanup() { cleanupTestFiles(); }
private slots:
void getSetCheck();
void ctor_data();
void ctor_data() { populateWithFormats(); }
void ctor();
void beginGroup();
void setValue();
@ -127,16 +137,16 @@ private slots:
void syncAlternateDataStream();
#endif
void setFallbacksEnabled();
void setFallbacksEnabled_data();
void fromFile_data();
void setFallbacksEnabled_data() { populateWithFormats(); }
void fromFile_data() { populateWithFormats(); }
void fromFile();
void testArrays_data();
void testArrays_data() { populateWithFormats(); }
void testArrays();
void testCaseSensitivity_data();
void testCaseSensitivity_data() { populateWithFormats(); }
void testCaseSensitivity();
void testErrorHandling_data();
void testErrorHandling();
void testChildKeysAndGroups_data();
void testChildKeysAndGroups_data() { populateWithFormats(); }
void testChildKeysAndGroups();
void testUpdateRequestEvent();
void testThreadSafety();
@ -149,7 +159,7 @@ private slots:
#ifdef Q_OS_MAC
void fileName();
#endif
void isWritable_data();
void isWritable_data() { populateWithFormats(); }
void isWritable();
void registerFormat();
void setPath();
@ -163,23 +173,23 @@ private slots:
#endif
#ifdef QT_BUILD_INTERNAL
void allKeys_data();
void allKeys_data() { populateWithFormats(); }
void allKeys();
void childGroups_data();
void childGroups_data() { populateWithFormats(); }
void childGroups();
void childKeys_data();
void childKeys_data() { populateWithFormats(); }
void childKeys();
void testIniParsing_data();
void testIniParsing();
void testEscapes();
void testNormalizedKey_data();
void testNormalizedKey();
void testVariantTypes_data();
void testVariantTypes_data() { populateWithFormats(); }
void testVariantTypes();
void testMetaTypes_data();
void testMetaTypes();
#endif
void rainersSyncBugOnMac_data();
void rainersSyncBugOnMac_data() { populateWithFormats(); }
void rainersSyncBugOnMac();
void recursionBug();
@ -279,16 +289,6 @@ static bool writeCustom3File(QIODevice &device, const QSettings::SettingsMap &ma
return true;
}
static void populateWithFormats()
{
QTest::addColumn<QSettings::Format>("format");
QTest::newRow("native") << QSettings::NativeFormat;
QTest::newRow("ini") << QSettings::IniFormat;
QTest::newRow("custom1") << QSettings::CustomFormat1;
QTest::newRow("custom2") << QSettings::CustomFormat2;
}
tst_QSettings::tst_QSettings()
: m_canWriteNativeSystemSettings(canWriteNativeSystemSettings())
{
@ -360,11 +360,6 @@ void tst_QSettings::cleanupTestFiles()
Test the constructors and the assignment operator.
*/
void tst_QSettings::ctor_data()
{
populateWithFormats();
}
void tst_QSettings::ctor()
{
QFETCH(QSettings::Format, format);
@ -1276,11 +1271,6 @@ FOR_EACH_CORE_METATYPE(RETURN_CREATE_FUNCTION)
TypeTestFunctionGetter::get(type)(format);
}
void tst_QSettings::testVariantTypes_data()
{
populateWithFormats();
}
#endif
#ifdef QT_BUILD_INTERNAL
@ -1359,6 +1349,7 @@ void tst_QSettings::testVariantTypes()
QList<QVariant> l4;
l4 << QVariant(m2) << QVariant(l2) << QVariant(l3);
testVal("key13", l4, QVariantList, List);
QDateTime dt = QDateTime::currentDateTime();
dt.setOffsetFromUtc(3600);
testVal("key14", dt, QDateTime, DateTime);
@ -1863,11 +1854,6 @@ void tst_QSettings::syncAlternateDataStream()
}
#endif
void tst_QSettings::setFallbacksEnabled_data()
{
populateWithFormats();
}
void tst_QSettings::setFallbacksEnabled()
{
QFETCH(QSettings::Format, format);
@ -1952,11 +1938,6 @@ void tst_QSettings::setFallbacksEnabled()
QVERIFY(!settings1.contains("key 5"));
}
void tst_QSettings::testChildKeysAndGroups_data()
{
populateWithFormats();
}
void tst_QSettings::testChildKeysAndGroups()
{
QFETCH(QSettings::Format, format);
@ -2351,11 +2332,6 @@ void tst_QSettings::trailingWhitespace()
}
}
void tst_QSettings::fromFile_data()
{
populateWithFormats();
}
void tst_QSettings::fromFile()
{
QFETCH(QSettings::Format, format);
@ -2425,11 +2401,6 @@ static bool containsSubList(QStringList mom, QStringList son)
return true;
}
void tst_QSettings::testArrays_data()
{
populateWithFormats();
}
/*
Tests beginReadArray(), beginWriteArray(), endArray(), and
setArrayIndex().
@ -2877,11 +2848,6 @@ void tst_QSettings::testEscapes()
}
#endif
void tst_QSettings::testCaseSensitivity_data()
{
populateWithFormats();
}
void tst_QSettings::testCaseSensitivity()
{
QFETCH(QSettings::Format, format);
@ -3031,11 +2997,6 @@ void tst_QSettings::fileName()
}
#endif
void tst_QSettings::isWritable_data()
{
populateWithFormats();
}
void tst_QSettings::isWritable()
{
QFETCH(QSettings::Format, format);
@ -3087,13 +3048,6 @@ void tst_QSettings::isWritable()
}
}
#ifdef QT_BUILD_INTERNAL
void tst_QSettings::childGroups_data()
{
populateWithFormats();
}
#endif
#ifdef QT_BUILD_INTERNAL
void tst_QSettings::childGroups()
{
@ -3163,13 +3117,6 @@ void tst_QSettings::childGroups()
}
#endif
#ifdef QT_BUILD_INTERNAL
void tst_QSettings::childKeys_data()
{
populateWithFormats();
}
#endif
#ifdef QT_BUILD_INTERNAL
void tst_QSettings::childKeys()
{
@ -3237,13 +3184,6 @@ void tst_QSettings::childKeys()
}
#endif
#ifdef QT_BUILD_INTERNAL
void tst_QSettings::allKeys_data()
{
populateWithFormats();
}
#endif
#ifdef QT_BUILD_INTERNAL
void tst_QSettings::allKeys()
{
@ -3504,11 +3444,6 @@ void tst_QSettings::dontReorderIniKeysNeedlessly()
}
#endif
void tst_QSettings::rainersSyncBugOnMac_data()
{
ctor_data();
}
void tst_QSettings::rainersSyncBugOnMac()
{
QFETCH(QSettings::Format, format);