From b55f10b2a05a328674aa39e8f7554963ab181278 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 14 Feb 2022 10:55:30 +0100 Subject: [PATCH] Convert a table iteration to use ranged-for The loop used an int counter that was initialized from a size_t, provoking a warning from MSVC. Since the indexing is irrelevant in any case, use a ranged-for loop. Since the loop was formerly in decreasing index order, reverse the table being iterated so that entries remain in their prior order. Change-Id: I79b93c5a3f39a502b0cae83215b8e3665d0e17f5 Reviewed-by: Marc Mutz --- .../corelib/time/qtimezone/tst_qtimezone.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp index a9d552fd03c..998838e1ff0 100644 --- a/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2021 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -596,19 +596,15 @@ void tst_QTimeZone::transitionEachZone_data() int start, stop; int year; } table[] = { - { 25666200, 3, 12, 1970 }, // 1970-10-25 01:30 UTC; North America - { 1288488600, -4, 8, 2010 } // 2010-10-31 01:30 UTC; Europe, Russia + { 1288488600, -4, 8, 2010 }, // 2010-10-31 01:30 UTC; Europe, Russia + { 25666200, 3, 12, 1970 }, // 1970-10-25 01:30 UTC; North America }; const auto zones = QTimeZone::availableTimeZoneIds(); - for (int k = std::size(table); k-- > 0; ) { + for (const auto &entry : table) { for (const QByteArray &zone : zones) { - const QString name = QString::asprintf("%s@%d", zone.constData(), table[k].year); - QTest::newRow(name.toUtf8().constData()) - << zone - << table[k].baseSecs - << table[k].start - << table[k].stop; + QTest::addRow("%s@%d", zone.constData(), entry.year) + << zone << entry.baseSecs << entry.start << entry.stop; } } }