diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-05-23 20:12:12 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-05-23 18:18:44 +0000 |
commit | fe5a157cbe37d2516ca69c92c4ec989ce77a25a2 (patch) | |
tree | ab3033995e6e7d24dfd846913edce4827deef381 /tests/auto/linguist/lupdate | |
parent | f377c9ce92be7f5ef82abbf585d88dd9f46a8811 (diff) | |
download | qttools-fe5a157cbe37d2516ca69c92c4ec989ce77a25a2.tar.gz |
tests: remove uses of Q_FOREACH
All pretty straight-forward, except two:
- in tst_QHelpPrjectData::filterSections(), use QCOMPARE() on two
lists instead of running it by hand. To allow for variation in
order, sort the list under test, and make sure the reference list is
sorted, too.
- in tst_QHelpEngineCore::files(), the trailing printing of 'lst' was
dead code: either the QCOMPARE succeeded, then 'lst' was empty, or
it failed, in which case QCOMPARE exits the function. The loop was
obviously meant to show the remaining items in case the test fails,
so stuff the loop (w/o Q_FOREACH) into a scope guard.
QtC tricked me into believing that these were the only occurrences in
this module. Alas, it just failed to parse large parts of the module's
pro-files. The module continues to be one of the worst offenders
w.r.t. Q_FOREACH with qdoc and linguist each containing ~150
instances, as well as macdeploy with a another dozen or two. The rest
is clean now.
Change-Id: I89f37ef07ab284da7881d624d9111e89cd2b2cbc
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'tests/auto/linguist/lupdate')
-rw-r--r-- | tests/auto/linguist/lupdate/tst_lupdate.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/auto/linguist/lupdate/tst_lupdate.cpp b/tests/auto/linguist/lupdate/tst_lupdate.cpp index ea049a1f9..c55167a55 100644 --- a/tests/auto/linguist/lupdate/tst_lupdate.cpp +++ b/tests/auto/linguist/lupdate/tst_lupdate.cpp @@ -223,7 +223,7 @@ void tst_lupdate::good_data() dirs.removeAll(QLatin1String("backslashes")); #endif - foreach (const QString &dir, dirs) + for (const QString &dir : qAsConst(dirs)) QTest::newRow(dir.toLocal8Bit()) << dir; } @@ -253,7 +253,8 @@ void tst_lupdate::good() } else if (cmdstring.startsWith("TRANSLATION:")) { cmdstring.remove(0, 12); generatedtsfiles.clear(); - foreach (const QByteArray &s, cmdstring.split(' ')) + const auto parts = cmdstring.split(' '); + for (const QByteArray &s : parts) if (!s.isEmpty()) generatedtsfiles << s; } else if (cmdstring.startsWith("cd ")) { @@ -264,7 +265,7 @@ void tst_lupdate::good() file.close(); } - foreach (const QString &ts, generatedtsfiles) { + for (const QString &ts : qAsConst(generatedtsfiles)) { QString genTs = workDir + QLatin1Char('/') + ts; QFile::remove(genTs); QString beforetsfile = dir + QLatin1Char('/') + ts + QLatin1String(".before"); @@ -304,7 +305,7 @@ void tst_lupdate::good() return; } - foreach (const QString &ts, generatedtsfiles) + for (const QString &ts : qAsConst(generatedtsfiles)) doCompare(workDir + QLatin1Char('/') + ts, dir + QLatin1Char('/') + ts + QLatin1String(".result"), false); } |