diff options
Diffstat (limited to 'tests/benchmarks/corelib/time/qtimezone/tst_bench_qtimezone.cpp')
-rw-r--r-- | tests/benchmarks/corelib/time/qtimezone/tst_bench_qtimezone.cpp | 77 |
1 files changed, 29 insertions, 48 deletions
diff --git a/tests/benchmarks/corelib/time/qtimezone/tst_bench_qtimezone.cpp b/tests/benchmarks/corelib/time/qtimezone/tst_bench_qtimezone.cpp index 36bb1dd24f..db8b910d98 100644 --- a/tests/benchmarks/corelib/time/qtimezone/tst_bench_qtimezone.cpp +++ b/tests/benchmarks/corelib/time/qtimezone/tst_bench_qtimezone.cpp @@ -1,31 +1,7 @@ -/**************************************************************************** -** -** Copyright (C) 2019 Crimson AS <info@crimson.no> -** Copyright (C) 2018 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2022 The Qt Company Ltd. +// Copyright (C) 2019 Crimson AS <info@crimson.no> +// Copyright (C) 2018 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QTimeZone> #include <QTest> @@ -39,6 +15,7 @@ class tst_QTimeZone : public QObject Q_OBJECT private Q_SLOTS: +#if QT_CONFIG(timezone) void isTimeZoneIdAvailable(); void systemTimeZone(); void zoneByName_data(); @@ -49,31 +26,35 @@ private Q_SLOTS: void transitionsForward(); void transitionsReverse_data() { transitionList_data(); } void transitionsReverse(); +#endif }; static QList<QByteArray> enoughZones() { #ifdef EXHAUSTIVE - auto available = QTimeZone::availableTimeZoneIds(); - QList<QByteArray> result; - result.reserve(available.size() + 1); - for (conat auto &name : available) - result << name; + QList<QByteArray> result = QTimeZone::availableTimeZoneIds(); #else - QList<QByteArray> result { QByteArray("UTC"), - // Those named overtly in tst_QDateTime: - QByteArray("Europe/Oslo"), QByteArray("America/Vancouver"), - QByteArray("Europe/Berlin"), QByteArray("America/Sao_Paulo"), - QByteArray("Pacific/Auckland"), QByteArray("Australia/Eucla"), - QByteArray("Asia/Kathmandu"), QByteArray("Pacific/Kiritimati"), - QByteArray("Pacific/Apia"), QByteArray("UTC+12:00"), - QByteArray("Australia/Sydney"), QByteArray("Asia/Singapore"), - QByteArray("Australia/Brisbane") }; + QList<QByteArray> result { + QByteArray("UTC"), + // Those named overtly in tst_QDateTime - special cases first: + QByteArray("UTC-02:00"), QByteArray("UTC+02:00"), QByteArray("UTC+12:00"), + QByteArray("Etc/GMT+3"), QByteArray("GMT-2"), QByteArray("GMT"), + // ... then ordinary names in alphabetic order: + QByteArray("America/New_York"), QByteArray("America/Sao_Paulo"), + QByteArray("America/Vancouver"), + QByteArray("Asia/Kathmandu"), QByteArray("Asia/Singapore"), + QByteArray("Australia/Brisbane"), QByteArray("Australia/Eucla"), + QByteArray("Australia/Sydney"), + QByteArray("Europe/Berlin"), QByteArray("Europe/Helsinki"), + QByteArray("Europe/Rome"), QByteArray("Europe/Oslo"), + QByteArray("Pacific/Apia"), QByteArray("Pacific/Auckland"), + QByteArray("Pacific/Kiritimati") + }; #endif result << QByteArray("Vulcan/ShiKahr"); // invalid: also worth testing return result; } - +#if QT_CONFIG(timezone) void tst_QTimeZone::isTimeZoneIdAvailable() { const QList<QByteArray> available = QTimeZone::availableTimeZoneIds(); @@ -89,7 +70,6 @@ void tst_QTimeZone::systemTimeZone() QTimeZone::systemTimeZone(); } } - void tst_QTimeZone::zoneByName_data() { QTest::addColumn<QByteArray>("name"); @@ -126,9 +106,9 @@ void tst_QTimeZone::transitionList() { QFETCH(QByteArray, name); const QTimeZone zone = name.isEmpty() ? QTimeZone::systemTimeZone() : QTimeZone(name); - const QDateTime early = QDate(1625, 6, 8).startOfDay(Qt::UTC); // Cassini's birth date + const QDateTime early = QDate(1625, 6, 8).startOfDay(QTimeZone::UTC); // Cassini's birth date const QDateTime late // End of 32-bit signed time_t - = QDateTime::fromSecsSinceEpoch(std::numeric_limits<qint32>::max(), Qt::UTC); + = QDateTime::fromSecsSinceEpoch(std::numeric_limits<qint32>::max(), QTimeZone::UTC); QTimeZone::OffsetDataList seq; QBENCHMARK { seq = zone.transitions(early, late); @@ -140,7 +120,7 @@ void tst_QTimeZone::transitionsForward() { QFETCH(QByteArray, name); const QTimeZone zone = name.isEmpty() ? QTimeZone::systemTimeZone() : QTimeZone(name); - const QDateTime early = QDate(1625, 6, 8).startOfDay(Qt::UTC); // Cassini's birth date + const QDateTime early = QDate(1625, 6, 8).startOfDay(QTimeZone::UTC); // Cassini's birth date QBENCHMARK { QTimeZone::OffsetData tran = zone.nextTransition(early); while (tran.atUtc.isValid()) @@ -153,13 +133,14 @@ void tst_QTimeZone::transitionsReverse() QFETCH(QByteArray, name); const QTimeZone zone = name.isEmpty() ? QTimeZone::systemTimeZone() : QTimeZone(name); const QDateTime late // End of 32-bit signed time_t - = QDateTime::fromSecsSinceEpoch(std::numeric_limits<qint32>::max(), Qt::UTC); + = QDateTime::fromSecsSinceEpoch(std::numeric_limits<qint32>::max(), QTimeZone::UTC); QBENCHMARK { QTimeZone::OffsetData tran = zone.previousTransition(late); while (tran.atUtc.isValid()) tran = zone.previousTransition(tran.atUtc); } } +#endif QTEST_MAIN(tst_QTimeZone) |