From 17b8a49fded383ffff1bd8552b55e8b5c01b2ecc Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 12 Nov 2019 14:22:26 +0100 Subject: Move some tests of QTimeZonePrivate::isValidId() to where they belong They were tucked away in the back-end of the isTimeZoneIdAvailable() test, but a separate isValidId() test had been added more recently, which made some (arguably all) of them redundant. Reworked this test in the process, so that the QSKIP() happens in _data() once instead of in the test that's never run because there are no data rows. Change-Id: Icaa6227ace9a1aa944d085691cdcfb3adf4a51dc Reviewed-by: Thiago Macieira --- .../auto/corelib/time/qtimezone/tst_qtimezone.cpp | 52 ++++++++++------------ 1 file changed, 24 insertions(+), 28 deletions(-) (limited to 'tests/auto/corelib/time') diff --git a/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp index 9904719f7c..9f51ff8ba8 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) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -377,31 +377,6 @@ void tst_QTimeZone::isTimeZoneIdAvailable() QList available = QTimeZone::availableTimeZoneIds(); foreach (const QByteArray &id, available) QVERIFY(QTimeZone::isTimeZoneIdAvailable(id)); - -#ifdef QT_BUILD_INTERNAL - // a-z, A-Z, 0-9, '.', '-', '_' are valid chars - // Can't start with '-' - // Parts separated by '/', each part min 1 and max of 14 chars - QCOMPARE(QTimeZonePrivate::isValidId("az"), true); - QCOMPARE(QTimeZonePrivate::isValidId("AZ"), true); - QCOMPARE(QTimeZonePrivate::isValidId("09"), true); - QCOMPARE(QTimeZonePrivate::isValidId("a/z"), true); - QCOMPARE(QTimeZonePrivate::isValidId("a.z"), true); - QCOMPARE(QTimeZonePrivate::isValidId("a-z"), true); - QCOMPARE(QTimeZonePrivate::isValidId("a_z"), true); - QCOMPARE(QTimeZonePrivate::isValidId(".z"), true); - QCOMPARE(QTimeZonePrivate::isValidId("_z"), true); - QCOMPARE(QTimeZonePrivate::isValidId("12345678901234"), true); - QCOMPARE(QTimeZonePrivate::isValidId("12345678901234/12345678901234"), true); - QCOMPARE(QTimeZonePrivate::isValidId("a z"), false); - QCOMPARE(QTimeZonePrivate::isValidId("a\\z"), false); - QCOMPARE(QTimeZonePrivate::isValidId("a,z"), false); - QCOMPARE(QTimeZonePrivate::isValidId("/z"), false); - QCOMPARE(QTimeZonePrivate::isValidId("-z"), false); - QCOMPARE(QTimeZonePrivate::isValidId("123456789012345"), false); - QCOMPARE(QTimeZonePrivate::isValidId("123456789012345/12345678901234"), false); - QCOMPARE(QTimeZonePrivate::isValidId("12345678901234/123456789012345"), false); -#endif // QT_BUILD_INTERNAL } void tst_QTimeZone::specificTransition_data() @@ -728,6 +703,9 @@ void tst_QTimeZone::isValidId_data() QTest::addColumn("input"); QTest::addColumn("valid"); + // a-z, A-Z, 0-9, '.', '-', '_' are valid chars + // Can't start with '-' + // Parts separated by '/', each part min 1 and max of 14 chars #define TESTSET(name, section, valid) \ QTest::newRow(name " front") << QByteArray(section "/xyz/xyz") << valid; \ QTest::newRow(name " middle") << QByteArray("xyz/" section "/xyz") << valid; \ @@ -766,6 +744,26 @@ void tst_QTimeZone::isValidId_data() TESTSET("invalid char ' '", " ", false); #undef TESTSET + + QTest::newRow("az alone") << QByteArray("az") << true; + QTest::newRow("AZ alone") << QByteArray("AZ") << true; + QTest::newRow("09 alone") << QByteArray("09") << true; + QTest::newRow("a/z alone") << QByteArray("a/z") << true; + QTest::newRow("a.z alone") << QByteArray("a.z") << true; + QTest::newRow("a-z alone") << QByteArray("a-z") << true; + QTest::newRow("a_z alone") << QByteArray("a_z") << true; + QTest::newRow(".z alone") << QByteArray(".z") << true; + QTest::newRow("_z alone") << QByteArray("_z") << true; + QTest::newRow("a z alone") << QByteArray("a z") << false; + QTest::newRow("a\\z alone") << QByteArray("a\\z") << false; + QTest::newRow("a,z alone") << QByteArray("a,z") << false; + QTest::newRow("/z alone") << QByteArray("/z") << false; + QTest::newRow("-z alone") << QByteArray("-z") << false; + QTest::newRow("long alone") << QByteArray("12345678901234") << true; + QTest::newRow("over-long alone") << QByteArray("123456789012345") << false; + +#else + QSKIP("This test requires a Qt -developer-build."); #endif // QT_BUILD_INTERNAL } @@ -776,8 +774,6 @@ void tst_QTimeZone::isValidId() QFETCH(bool, valid); QCOMPARE(QTimeZonePrivate::isValidId(input), valid); -#else - QSKIP("This test requires a Qt -developer-build."); #endif } -- cgit v1.2.3 From ad11cab4842a4d35fe80641ae3eec7f2d8817652 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 10 Aug 2018 12:17:49 +0200 Subject: Allow longer time-zone components on Android MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Android uses its own time-zone naming, which includes a zone called "Canada/East-Saskatchewan", whose second component is 17 characters long. This violates a rule in the IANA naming scheme for zones, that limits components to 14 characters each. So tweak the isValidId() check to allow Android its long names. Android has added Outer Mongolian time-zones, which are as borked as many others in 1970, so blacklist those transitionEachZone() tests. Fixes: QTBUG-69128 Change-Id: I46f674f095431335b16900860d83b624257ae3bb Reviewed-by: Jan Arve Sæther --- tests/auto/corelib/time/qtimezone/BLACKLIST | 12 ++++++++---- tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp | 11 +++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) (limited to 'tests/auto/corelib/time') diff --git a/tests/auto/corelib/time/qtimezone/BLACKLIST b/tests/auto/corelib/time/qtimezone/BLACKLIST index 840c3b1181..b820bab3d9 100644 --- a/tests/auto/corelib/time/qtimezone/BLACKLIST +++ b/tests/auto/corelib/time/qtimezone/BLACKLIST @@ -2,10 +2,6 @@ [dataStreamTest] android -# QTBUG-69128 -[isTimeZoneIdAvailable] -android - # QTBUG-69129 [specificTransition] android @@ -75,10 +71,14 @@ android android [transitionEachZone:Asia/Chita@1970] android +[transitionEachZone:Asia/Choibalsan@1970] +android [transitionEachZone:Asia/Dushanbe@1970] android [transitionEachZone:Asia/Ho_Chi_Minh@1970] android +[transitionEachZone:Asia/Hovd@1970] +android [transitionEachZone:Asia/Kathmandu@1970] android [transitionEachZone:Asia/Katmandu@1970] @@ -109,6 +109,10 @@ android android [transitionEachZone:Asia/Thimphu@1970] android +[transitionEachZone:Asia/Ulaanbaatar@1970] +android +[transitionEachZone:Asia/Ulan_Bator@1970] +android [transitionEachZone:Asia/Ust-Nera@1970] android [transitionEachZone:Atlantic/Cape_Verde@1970] diff --git a/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp index 9f51ff8ba8..f425691d9c 100644 --- a/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp @@ -706,6 +706,7 @@ void tst_QTimeZone::isValidId_data() // a-z, A-Z, 0-9, '.', '-', '_' are valid chars // Can't start with '-' // Parts separated by '/', each part min 1 and max of 14 chars + // (Android has parts with lengths up to 17, so tolerates this as a special case.) #define TESTSET(name, section, valid) \ QTest::newRow(name " front") << QByteArray(section "/xyz/xyz") << valid; \ QTest::newRow(name " middle") << QByteArray("xyz/" section "/xyz") << valid; \ @@ -713,8 +714,13 @@ void tst_QTimeZone::isValidId_data() TESTSET("empty", "", false); TESTSET("minimal", "m", true); +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED) + TESTSET("maximal", "East-Saskatchewan", true); // Android actually uses this + TESTSET("too long", "North-Saskatchewan", false); // ... but thankfully not this. +#else TESTSET("maximal", "12345678901234", true); TESTSET("too long", "123456789012345", false); +#endif TESTSET("bad hyphen", "-hyphen", false); TESTSET("good hyphen", "hy-phen", true); @@ -759,8 +765,13 @@ void tst_QTimeZone::isValidId_data() QTest::newRow("a,z alone") << QByteArray("a,z") << false; QTest::newRow("/z alone") << QByteArray("/z") << false; QTest::newRow("-z alone") << QByteArray("-z") << false; +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED) + QTest::newRow("long alone") << QByteArray("12345678901234567") << true; + QTest::newRow("over-long alone") << QByteArray("123456789012345678") << false; +#else QTest::newRow("long alone") << QByteArray("12345678901234") << true; QTest::newRow("over-long alone") << QByteArray("123456789012345") << false; +#endif #else QSKIP("This test requires a Qt -developer-build."); -- cgit v1.2.3