Use ranged for loops in place of foreach in QTimeZone tests

This (and use of Q_SLOTS for the test slots) makes it possible to
enable QT_NO_KEYWORDS and QT_NO_FOREACH in all the corelib/time/
tests.

Change-Id: I85fd358f3d1a72c9269d5260d0224640c1751f2d
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This commit is contained in:
Edward Welbourne 2019-03-22 14:29:05 +01:00
parent 21b5c7875c
commit f6d1be7c66
8 changed files with 15 additions and 13 deletions

View File

@ -2,3 +2,4 @@ CONFIG += testcase
TARGET = tst_qdate
QT = core-private testlib
SOURCES = tst_qdate.cpp
DEFINES += QT_NO_KEYWORDS QT_NO_FOREACH

View File

@ -35,7 +35,7 @@
class tst_QDate : public QObject
{
Q_OBJECT
private slots:
private Q_SLOTS:
void isNull_data();
void isNull();
void isValid_data();

View File

@ -2,6 +2,7 @@ CONFIG += testcase
TARGET = tst_qdatetime
QT = core-private testlib
SOURCES = tst_qdatetime.cpp
DEFINES += QT_NO_KEYWORDS QT_NO_FOREACH
# For some reason using optimization here triggers a compiler issue, which causes an exception
# However, the code is correct

View File

@ -48,10 +48,10 @@ public:
static QString str( int y, int month, int d, int h, int min, int s );
static QDateTime dt( const QString& str );
public slots:
public Q_SLOTS:
void initTestCase();
void init();
private slots:
private Q_SLOTS:
void ctor();
void operator_eq();
void isNull();

View File

@ -2,3 +2,4 @@ CONFIG += testcase
TARGET = tst_qtime
QT = core testlib
SOURCES = tst_qtime.cpp
DEFINES += QT_NO_KEYWORDS QT_NO_FOREACH

View File

@ -48,7 +48,7 @@ public:
}
#endif // remove for ### Qt 6
private slots:
private Q_SLOTS:
void msecsTo_data();
void msecsTo();
void secsTo_data();

View File

@ -2,10 +2,9 @@ CONFIG += testcase
TARGET = tst_qtimezone
QT = core-private testlib
SOURCES = tst_qtimezone.cpp
qtConfig(icu) {
QMAKE_USE_PRIVATE += icu
}
DEFINES += QT_NO_KEYWORDS QT_NO_FOREACH
qtConfig(icu): QMAKE_USE_PRIVATE += icu
darwin {
OBJECTIVE_SOURCES += tst_qtimezone_darwin.mm
LIBS += -framework Foundation

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2019 The Qt Company Ltd.
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@ -42,7 +42,7 @@ class tst_QTimeZone : public QObject
public:
tst_QTimeZone();
private slots:
private Q_SLOTS:
// Public class default system tests
void createTest();
void nullTest();
@ -385,8 +385,8 @@ void tst_QTimeZone::dataStreamTest()
void tst_QTimeZone::isTimeZoneIdAvailable()
{
QList<QByteArray> available = QTimeZone::availableTimeZoneIds();
foreach (const QByteArray &id, available) {
const QList<QByteArray> available = QTimeZone::availableTimeZoneIds();
for (const QByteArray &id : available) {
QVERIFY(QTimeZone::isTimeZoneIdAvailable(id));
QVERIFY(QTimeZone(id).isValid());
}
@ -701,8 +701,8 @@ void tst_QTimeZone::availableTimeZoneIds()
void tst_QTimeZone::stressTest()
{
QList<QByteArray> idList = QTimeZone::availableTimeZoneIds();
foreach (const QByteArray &id, idList) {
const QList<QByteArray> idList = QTimeZone::availableTimeZoneIds();
for (const QByteArray &id : idList) {
QTimeZone testZone = QTimeZone(id);
QCOMPARE(testZone.isValid(), true);
QCOMPARE(testZone.id(), id);