From 2fa5a525a3ebfea2fdf7da755c8ac2e04ee79820 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 5 Dec 2024 14:31:21 +0100 Subject: [PATCH] Cope with IANA DB links that aren't in the CLDR alias mapping As documented in the LMDL spec (see comment on unAliasedLinks in the diff) not all links in the IANA DB are represented as CLDR aliases. This didn't surface until a recent update to the IANA DB used symlinks more aggressively. Add a set of known cases of this to exclude from hasAlternativeName() checks and let's hope it doesn't grow too often. Pick to 6.8 required #include that was transitively available on dev but not on 6.8 Change-Id: Ia12d9fcad96485469ded6bdb7345a400bd34efae Reviewed-by: Thiago Macieira (cherry picked from commit ae6b6bf363d71184269104e4bfbb19a9abd27a24) --- .../corelib/time/qtimezone/tst_qtimezone.cpp | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp index c5745a1dccf..bb938f069cf 100644 --- a/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp @@ -13,6 +13,8 @@ #include #endif +#include + #if defined(Q_OS_WIN) && !QT_CONFIG(icu) # define USING_WIN_TZ #endif @@ -70,11 +72,32 @@ private Q_SLOTS: private: void printTimeZone(const QTimeZone &tz); -#if defined(QT_BUILD_INTERNAL) && QT_CONFIG(timezone) +#if QT_CONFIG(timezone) +# if defined(QT_BUILD_INTERNAL) // Generic tests of privates, called by implementation-specific private tests: void testCetPrivate(const QTimeZonePrivate &tzp); void testEpochTranPrivate(const QTimeZonePrivate &tzp); -#endif // QT_BUILD_INTERNAL && timezone backends +# endif // QT_BUILD_INTERNAL + // Where tzdb contains a link between zones in different territories, CLDR + // doesn't treat those as aliases for one another. For details see "Links in + // the tz database" at: + // https://www.unicode.org/reports/tr35/#time-zone-identifiers + // Some of these could be identified as equivalent by looking at metazone + // histories but, for now, we stick with CLDR's notion of alias. + const std::set unAliasedLinks = { + // By continent: + "America/Kralendijk", "America/Lower_Princes", "America/Marigot", "America/St_Barthelemy", + "Antarctica/South_Pole", + "Arctic/Longyearbyen", + "Asia/Choibalsan", + "Atlantic/Jan_Mayen", + "Europe/Bratislava", "Europe/Busingen", "Europe/Mariehamn", + "Europe/Podgorica", "Europe/San_Marino", "Europe/Vatican", + // Assorted legacy abbreviations and POSIX zones: + "CET", "EET", "EST", "HST", "MET", "MST", "WET", + "CST6CDT", "EST5EDT", "MST7MDT", "PST8PDT", + }; +#endif // timezone backends // Set to true to print debug output, test Display Names and run long stress tests static constexpr bool debug = false; }; @@ -565,7 +588,8 @@ void tst_QTimeZone::isTimeZoneIdAvailable() QVERIFY2(QTimeZone::isTimeZoneIdAvailable(id), id); const QTimeZone zone(id); QVERIFY2(zone.isValid(), id); - QVERIFY2(zone.hasAlternativeName(id), zone.id() + " != " + id); + if (unAliasedLinks.find(id) == unAliasedLinks.end()) + QVERIFY2(zone.hasAlternativeName(id), zone.id() + " != " + id); } // availableTimeZoneIds() doesn't list all possible offset IDs, but // isTimeZoneIdAvailable() should accept them. @@ -995,7 +1019,8 @@ void tst_QTimeZone::stressTest() for (const QByteArray &id : idList) { QTimeZone testZone = QTimeZone(id); QCOMPARE(testZone.isValid(), true); - QVERIFY2(testZone.hasAlternativeName(id), testZone.id() + " != " + id); + if (unAliasedLinks.find(id) == unAliasedLinks.end()) + QVERIFY2(testZone.hasAlternativeName(id), testZone.id() + " != " + id); QDateTime testDate = QDateTime(QDate(2015, 1, 1), QTime(0, 0), UTC); testZone.territory(); testZone.comment();