summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2017-10-31 10:58:31 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2017-11-30 20:20:29 +0000
commit92fad720af012eed1564cfa0338c52786b0eca6c (patch)
tree7cbd927ffc5ac2a9e37028811e453ed0f5f2a727
parent6deb0f0dcc202e1be08cb6a2284da266cd0fa956 (diff)
Add a check of selected time-zone offset data
Task-number: QTBUG-64122 Change-Id: I6b113f2f05db9659b8c542744846096e39f285ab Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp
index 6b103d355a..c8f32130cc 100644
--- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp
+++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp
@@ -47,6 +47,8 @@ private slots:
void availableTimeZoneIds();
void transitionEachZone_data();
void transitionEachZone();
+ void checkOffset_data();
+ void checkOffset();
void stressTest();
void windowsId();
void isValidId_data();
@@ -446,6 +448,51 @@ void tst_QTimeZone::transitionEachZone()
}
}
+void tst_QTimeZone::checkOffset_data()
+{
+ QTest::addColumn<QByteArray>("zoneName");
+ QTest::addColumn<QDateTime>("when");
+ QTest::addColumn<int>("netOffset");
+ QTest::addColumn<int>("stdOffset");
+ QTest::addColumn<int>("dstOffset");
+
+ struct {
+ const char *zone, *nick;
+ int year, month, day, hour, min, sec;
+ int std, dst;
+ } table[] = {
+ // Kiev: regression test for QTBUG-64122 (on MS):
+ { "Europe/Kiev", "summer", 2017, 10, 27, 12, 0, 0, 2 * 3600, 3600 },
+ { "Europe/Kiev", "winter", 2017, 10, 29, 12, 0, 0, 2 * 3600, 0 }
+ };
+ for (const auto &entry : table) {
+ QTimeZone zone(entry.zone);
+ if (zone.isValid()) {
+ QTest::addRow("%s@%s", entry.zone, entry.nick)
+ << QByteArray(entry.zone)
+ << QDateTime(QDate(entry.year, entry.month, entry.day),
+ QTime(entry.hour, entry.min, entry.sec), zone)
+ << entry.dst + entry.std << entry.std << entry.dst;
+ }
+ }
+}
+
+void tst_QTimeZone::checkOffset()
+{
+ QFETCH(QByteArray, zoneName);
+ QFETCH(QDateTime, when);
+ QFETCH(int, netOffset);
+ QFETCH(int, stdOffset);
+ QFETCH(int, dstOffset);
+
+ QTimeZone zone(zoneName);
+ QVERIFY(zone.isValid()); // It was when _data() added the row !
+ QCOMPARE(zone.offsetFromUtc(when), netOffset);
+ QCOMPARE(zone.standardTimeOffset(when), stdOffset);
+ QCOMPARE(zone.daylightTimeOffset(when), dstOffset);
+ QCOMPARE(zone.isDaylightTime(when), dstOffset != 0);
+}
+
void tst_QTimeZone::availableTimeZoneIds()
{
if (debug) {