diff options
author | Ahmad Samir <a.samirh78@gmail.com> | 2023-08-11 02:47:10 +0300 |
---|---|---|
committer | Ahmad Samir <a.samirh78@gmail.com> | 2023-08-19 16:28:33 +0300 |
commit | 645dcc27d3567a2a39baa11e37bd3e1dfb25e8f7 (patch) | |
tree | 8da17410721220577270312d43e13c24b12e8566 | |
parent | 0766d55d225126a855cf41649c8ed097cc14c528 (diff) |
tst_QAbstractFileEngine: compile with QT_NO_FOREACH
cleanupTestCase(): the loop doesn't modify the member container, so use
std::as_const and a ranged-for.
mounting(): the loop was iterating over a temporary QList, store it in a
local auto variable and use ranged-for.
Drive-by change: add braces to a multi-lined for block.
Task-number: QTBUG-115839
Change-Id: I0542cad4df3730d6a09b39e64a54a84fc0d57062
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
-rw-r--r-- | tests/auto/corelib/io/qabstractfileengine/tst_qabstractfileengine.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/auto/corelib/io/qabstractfileengine/tst_qabstractfileengine.cpp b/tests/auto/corelib/io/qabstractfileengine/tst_qabstractfileengine.cpp index 029ef37373..c62fa3571b 100644 --- a/tests/auto/corelib/io/qabstractfileengine/tst_qabstractfileengine.cpp +++ b/tests/auto/corelib/io/qabstractfileengine/tst_qabstractfileengine.cpp @@ -1,8 +1,6 @@ // Copyright (C) 2016 The Qt Company Ltd. // 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 <QtCore/private/qabstractfileengine_p.h> #include <QtCore/private/qfsfileengine_p.h> @@ -514,12 +512,13 @@ void tst_QAbstractFileEngine::cleanupTestCase() bool failed = false; FileEngineHandler handler; - Q_FOREACH(QString file, filesForRemoval) + for (const QString &file : std::as_const(filesForRemoval)) { if (!QFile::remove(file) || QFile::exists(file)) { failed = true; qDebug() << "Couldn't remove file:" << file; } + } QVERIFY(!failed); @@ -825,7 +824,8 @@ void tst_QAbstractFileEngine::mounting() QCOMPARE(dir.entryList(), (QStringList() << "bar" << "foo")); QDir dir2(fs.path()); bool found = false; - foreach (QFileInfo info, dir2.entryInfoList()) { + const auto entries = dir2.entryInfoList(); + for (const QFileInfo &info : entries) { if (info.fileName() == QLatin1String("test.tar")) { QVERIFY(!found); found = true; |