tst_QDir: compile with QT_NO_FOREACH
Each loop was iterating over temporary containers, so use a const auto variable to hold it and use ranged-for Drive-by change: make the for-loop variable a const& (QString, QFileInfo). Task-number: QTBUG-115839 Change-Id: Idffaedb8e2e8782a0f4f907995f62f3c0de44bba Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
9812df02db
commit
019554a399
@ -2,8 +2,6 @@
|
|||||||
// Copyright (C) 2017 Intel Corporation.
|
// Copyright (C) 2017 Intel Corporation.
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
|
|
||||||
|
|
||||||
#include <QTest>
|
#include <QTest>
|
||||||
#include <QTemporaryFile>
|
#include <QTemporaryFile>
|
||||||
#if QT_CONFIG(process)
|
#if QT_CONFIG(process)
|
||||||
@ -1867,9 +1865,9 @@ void tst_QDir::searchPaths()
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < searchPathPrefixList.size(); ++i) {
|
for (int i = 0; i < searchPathPrefixList.size(); ++i) {
|
||||||
foreach (QString path, searchPathsList.at(i).split(",")) {
|
const auto parts = searchPathsList.at(i).split(",");
|
||||||
|
for (const QString &path : parts)
|
||||||
QDir::addSearchPath(searchPathPrefixList.at(i), path);
|
QDir::addSearchPath(searchPathPrefixList.at(i), path);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (int i = 0; i < searchPathPrefixList.size(); ++i) {
|
for (int i = 0; i < searchPathPrefixList.size(); ++i) {
|
||||||
QCOMPARE(QDir::searchPaths(searchPathPrefixList.at(i)), searchPathsList.at(i).split(","));
|
QCOMPARE(QDir::searchPaths(searchPathPrefixList.at(i)), searchPathsList.at(i).split(","));
|
||||||
@ -2195,7 +2193,7 @@ void tst_QDir::match()
|
|||||||
|
|
||||||
void tst_QDir::drives()
|
void tst_QDir::drives()
|
||||||
{
|
{
|
||||||
QFileInfoList list(QDir::drives());
|
const QFileInfoList list(QDir::drives());
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
QVERIFY(list.count() >= 1); //system
|
QVERIFY(list.count() >= 1); //system
|
||||||
QLatin1Char systemdrive('c');
|
QLatin1Char systemdrive('c');
|
||||||
@ -2203,7 +2201,7 @@ void tst_QDir::drives()
|
|||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
QVERIFY(list.count() <= 26);
|
QVERIFY(list.count() <= 26);
|
||||||
bool foundsystem = false;
|
bool foundsystem = false;
|
||||||
foreach (QFileInfo fi, list) {
|
for (const QFileInfo &fi : list) {
|
||||||
QCOMPARE(fi.absolutePath().size(), 3); //"x:/"
|
QCOMPARE(fi.absolutePath().size(), 3); //"x:/"
|
||||||
QCOMPARE(fi.absolutePath().at(1), QChar(QLatin1Char(':')));
|
QCOMPARE(fi.absolutePath().at(1), QChar(QLatin1Char(':')));
|
||||||
QCOMPARE(fi.absolutePath().at(2), QChar(QLatin1Char('/')));
|
QCOMPARE(fi.absolutePath().at(2), QChar(QLatin1Char('/')));
|
||||||
@ -2327,9 +2325,9 @@ void tst_QDir::isRelative_data()
|
|||||||
QTest::newRow("homepath") << QDir::homePath() << false;
|
QTest::newRow("homepath") << QDir::homePath() << false;
|
||||||
QTest::newRow("temppath") << QDir::tempPath() << false;
|
QTest::newRow("temppath") << QDir::tempPath() << false;
|
||||||
QTest::newRow("rootpath") << QDir::rootPath() << false;
|
QTest::newRow("rootpath") << QDir::rootPath() << false;
|
||||||
foreach (QFileInfo root, QDir::drives()) {
|
const auto drives = QDir::drives();
|
||||||
|
for (const QFileInfo &root : drives)
|
||||||
QTest::newRow(root.absolutePath().toLocal8Bit()) << root.absolutePath() << false;
|
QTest::newRow(root.absolutePath().toLocal8Bit()) << root.absolutePath() << false;
|
||||||
}
|
|
||||||
|
|
||||||
QTest::newRow("resource") << ":/prefix" << false;
|
QTest::newRow("resource") << ":/prefix" << false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user