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:
parent
21b5c7875c
commit
f6d1be7c66
@ -2,3 +2,4 @@ CONFIG += testcase
|
|||||||
TARGET = tst_qdate
|
TARGET = tst_qdate
|
||||||
QT = core-private testlib
|
QT = core-private testlib
|
||||||
SOURCES = tst_qdate.cpp
|
SOURCES = tst_qdate.cpp
|
||||||
|
DEFINES += QT_NO_KEYWORDS QT_NO_FOREACH
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
class tst_QDate : public QObject
|
class tst_QDate : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private slots:
|
private Q_SLOTS:
|
||||||
void isNull_data();
|
void isNull_data();
|
||||||
void isNull();
|
void isNull();
|
||||||
void isValid_data();
|
void isValid_data();
|
||||||
|
@ -2,6 +2,7 @@ CONFIG += testcase
|
|||||||
TARGET = tst_qdatetime
|
TARGET = tst_qdatetime
|
||||||
QT = core-private testlib
|
QT = core-private testlib
|
||||||
SOURCES = tst_qdatetime.cpp
|
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
|
# For some reason using optimization here triggers a compiler issue, which causes an exception
|
||||||
# However, the code is correct
|
# However, the code is correct
|
||||||
|
@ -48,10 +48,10 @@ public:
|
|||||||
|
|
||||||
static QString str( int y, int month, int d, int h, int min, int s );
|
static QString str( int y, int month, int d, int h, int min, int s );
|
||||||
static QDateTime dt( const QString& str );
|
static QDateTime dt( const QString& str );
|
||||||
public slots:
|
public Q_SLOTS:
|
||||||
void initTestCase();
|
void initTestCase();
|
||||||
void init();
|
void init();
|
||||||
private slots:
|
private Q_SLOTS:
|
||||||
void ctor();
|
void ctor();
|
||||||
void operator_eq();
|
void operator_eq();
|
||||||
void isNull();
|
void isNull();
|
||||||
|
@ -2,3 +2,4 @@ CONFIG += testcase
|
|||||||
TARGET = tst_qtime
|
TARGET = tst_qtime
|
||||||
QT = core testlib
|
QT = core testlib
|
||||||
SOURCES = tst_qtime.cpp
|
SOURCES = tst_qtime.cpp
|
||||||
|
DEFINES += QT_NO_KEYWORDS QT_NO_FOREACH
|
||||||
|
@ -48,7 +48,7 @@ public:
|
|||||||
}
|
}
|
||||||
#endif // remove for ### Qt 6
|
#endif // remove for ### Qt 6
|
||||||
|
|
||||||
private slots:
|
private Q_SLOTS:
|
||||||
void msecsTo_data();
|
void msecsTo_data();
|
||||||
void msecsTo();
|
void msecsTo();
|
||||||
void secsTo_data();
|
void secsTo_data();
|
||||||
|
@ -2,10 +2,9 @@ CONFIG += testcase
|
|||||||
TARGET = tst_qtimezone
|
TARGET = tst_qtimezone
|
||||||
QT = core-private testlib
|
QT = core-private testlib
|
||||||
SOURCES = tst_qtimezone.cpp
|
SOURCES = tst_qtimezone.cpp
|
||||||
qtConfig(icu) {
|
DEFINES += QT_NO_KEYWORDS QT_NO_FOREACH
|
||||||
QMAKE_USE_PRIVATE += icu
|
|
||||||
}
|
|
||||||
|
|
||||||
|
qtConfig(icu): QMAKE_USE_PRIVATE += icu
|
||||||
darwin {
|
darwin {
|
||||||
OBJECTIVE_SOURCES += tst_qtimezone_darwin.mm
|
OBJECTIVE_SOURCES += tst_qtimezone_darwin.mm
|
||||||
LIBS += -framework Foundation
|
LIBS += -framework Foundation
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2019 The Qt Company Ltd.
|
** Copyright (C) 2020 The Qt Company Ltd.
|
||||||
** Contact: https://www.qt.io/licensing/
|
** Contact: https://www.qt.io/licensing/
|
||||||
**
|
**
|
||||||
** This file is part of the test suite of the Qt Toolkit.
|
** This file is part of the test suite of the Qt Toolkit.
|
||||||
@ -42,7 +42,7 @@ class tst_QTimeZone : public QObject
|
|||||||
public:
|
public:
|
||||||
tst_QTimeZone();
|
tst_QTimeZone();
|
||||||
|
|
||||||
private slots:
|
private Q_SLOTS:
|
||||||
// Public class default system tests
|
// Public class default system tests
|
||||||
void createTest();
|
void createTest();
|
||||||
void nullTest();
|
void nullTest();
|
||||||
@ -385,8 +385,8 @@ void tst_QTimeZone::dataStreamTest()
|
|||||||
|
|
||||||
void tst_QTimeZone::isTimeZoneIdAvailable()
|
void tst_QTimeZone::isTimeZoneIdAvailable()
|
||||||
{
|
{
|
||||||
QList<QByteArray> available = QTimeZone::availableTimeZoneIds();
|
const QList<QByteArray> available = QTimeZone::availableTimeZoneIds();
|
||||||
foreach (const QByteArray &id, available) {
|
for (const QByteArray &id : available) {
|
||||||
QVERIFY(QTimeZone::isTimeZoneIdAvailable(id));
|
QVERIFY(QTimeZone::isTimeZoneIdAvailable(id));
|
||||||
QVERIFY(QTimeZone(id).isValid());
|
QVERIFY(QTimeZone(id).isValid());
|
||||||
}
|
}
|
||||||
@ -701,8 +701,8 @@ void tst_QTimeZone::availableTimeZoneIds()
|
|||||||
|
|
||||||
void tst_QTimeZone::stressTest()
|
void tst_QTimeZone::stressTest()
|
||||||
{
|
{
|
||||||
QList<QByteArray> idList = QTimeZone::availableTimeZoneIds();
|
const QList<QByteArray> idList = QTimeZone::availableTimeZoneIds();
|
||||||
foreach (const QByteArray &id, idList) {
|
for (const QByteArray &id : idList) {
|
||||||
QTimeZone testZone = QTimeZone(id);
|
QTimeZone testZone = QTimeZone(id);
|
||||||
QCOMPARE(testZone.isValid(), true);
|
QCOMPARE(testZone.isValid(), true);
|
||||||
QCOMPARE(testZone.id(), id);
|
QCOMPARE(testZone.id(), id);
|
||||||
|
Loading…
Reference in New Issue
Block a user