summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qfileinfo
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2023-08-11 03:09:40 +0300
committerAhmad Samir <a.samirh78@gmail.com>2023-08-19 16:29:09 +0300
commite7b07b64c7b0536eccba6ff25e23badb88226813 (patch)
treed70ab6c7451f2e6b62887684fe3ab528d345a577 /tests/auto/corelib/io/qfileinfo
parentc7a8e1e9928fc2b84e6179adc69c858b17b25d48 (diff)
tests/auto/*: port Q_FOREACH to ranged-for
The loop was iterating over a temporary container, so it couldn't have changed it. Store the container in a const auto variable and use ranged-for. In files where Q_FOREACH isn't used any more, remove "#undef QT_NO_FOREACH". Task-number: QTBUG-115839 Change-Id: I402df5fa48f4287f3cc989ddae1524da43999049 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto/corelib/io/qfileinfo')
-rw-r--r--tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
index 97bada7668..e13b16260e 100644
--- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
@@ -1,8 +1,6 @@
// Copyright (C) 2021 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 <QTest>
#include <QStandardPaths>
#include <QScopeGuard>
@@ -1520,9 +1518,9 @@ void tst_QFileInfo::isHidden_data()
{
QTest::addColumn<QString>("path");
QTest::addColumn<bool>("isHidden");
- foreach (const QFileInfo& info, QDir::drives()) {
+ const auto drives = QDir::drives();
+ for (const QFileInfo& info : drives)
QTest::newRow(qPrintable("drive." + info.path())) << info.path() << false;
- }
#if defined(Q_OS_WIN)
QVERIFY(QDir("./hidden-directory").exists() || QDir().mkdir("./hidden-directory"));