summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/time
diff options
context:
space:
mode:
authorNicolas Fella <nicolas.fella@kdab.com>2021-08-22 19:21:45 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2024-02-08 15:40:03 +0100
commit00d9a9a9b59650b8e297f91dcc600c377da5bceb (patch)
treefc5f816d2883d554ec0e3ef712d915d303d01ae4 /tests/auto/corelib/time
parentb33b85cc46998133cddb18683402b6f0aaac754e (diff)
QIcuTimeZonePrivate constructor: save iteration over all zone IDs
ICU returns a "valid" representation of GMT when given an unrecognised ID, so QTZ's constructor has been checking the ID is available before passing it to the backend constructor. That availability check was done by generating the list of available IDs to see if the given ID was in it; this is very inefficient. Furthermore, the QTZ constructor was also checking availability, to work round the same issue in only this one backend, making the check redundant. So overide isTimeZoneIdAvailable() in the ICU backend, calling ucal_getCanonicalTimeZoneID(), which answers the question directly; and drop the duplicate check in the QTZ constructor. Expand a test to verify an invalid name is rejected. Fixes: QTBUG-121807 Pick-to: 6.7 6.6 6.5 Change-Id: I34f996b607b958d12607a94eb273bb1b406cca1a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/time')
-rw-r--r--tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
index 75c8e16fa5..a350ffeb04 100644
--- a/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+++ b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
@@ -1289,7 +1289,9 @@ void tst_QTimeZone::icuTest()
QIcuTimeZonePrivate tzpd;
QVERIFY(tzpd.isValid());
- // Test invalid constructor
+ // Test invalid is not available:
+ QVERIFY(!tzpd.isTimeZoneIdAvailable("Gondwana/Erewhon"));
+ // and construction gives an invalid result:
QIcuTimeZonePrivate tzpi("Gondwana/Erewhon");
QCOMPARE(tzpi.isValid(), false);