Clean up "Qt Standard Time" tests
These were using an offset of 123456 seconds = UTC+34:17:36, which is outside our supported range. This wasn't actually causing a problem, as it wasn't being checked, but we should stay within 16 hours of UTC. In the process, modernize the use of strings involved in its tests and change an initial value to something further from what shall overwrite it, rather than a neutral value. Change-Id: Ife4e082f1f00665d3203641508f5d30b34aaae75 Reviewed-by: Magdalena Stojek <magdalena.stojek@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> (cherry picked from commit 53ad78a636e4ca4f840213125c99841b7817195a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit d4f4cd2ef22cc4216950c0ba8d4e90a456c83f04)
This commit is contained in:
parent
6bbc587932
commit
0eb9b9523e
@ -489,26 +489,27 @@ void tst_QTimeZone::dataStreamTest()
|
||||
{
|
||||
#ifndef QT_NO_DATASTREAM
|
||||
// Test the OffsetFromUtc backend serialization. First with a custom timezone:
|
||||
QTimeZone tz1("QST", 123456, "Qt Standard Time", "QST", QLocale::Norway, "Qt Testing");
|
||||
QTimeZone tz1("QST"_ba, 23456,
|
||||
u"Qt Standard Time"_s, u"QST"_s, QLocale::Norway, u"Qt Testing"_s);
|
||||
QByteArray tmp;
|
||||
{
|
||||
QDataStream ds(&tmp, QIODevice::WriteOnly);
|
||||
ds << tz1;
|
||||
}
|
||||
QTimeZone tz2("UTC");
|
||||
QTimeZone tz2("UTC-12:00"); // Shall be over-written.
|
||||
{
|
||||
QDataStream ds(&tmp, QIODevice::ReadOnly);
|
||||
ds >> tz2;
|
||||
}
|
||||
QCOMPARE(tz2.id(), QByteArray("QST"));
|
||||
QCOMPARE(tz2.comment(), QString("Qt Testing"));
|
||||
QCOMPARE(tz2.id(), "QST"_ba);
|
||||
QCOMPARE(tz2.comment(), u"Qt Testing"_s);
|
||||
QCOMPARE(tz2.territory(), QLocale::Norway);
|
||||
QCOMPARE(tz2.abbreviation(QDateTime::currentDateTime()), QString("QST"));
|
||||
QCOMPARE(tz2.abbreviation(QDateTime::currentDateTime()), u"QST"_s);
|
||||
QCOMPARE(tz2.displayName(QTimeZone::StandardTime, QTimeZone::LongName, QLocale()),
|
||||
QString("Qt Standard Time"));
|
||||
u"Qt Standard Time"_s);
|
||||
QCOMPARE(tz2.displayName(QTimeZone::DaylightTime, QTimeZone::LongName, QLocale()),
|
||||
QString("Qt Standard Time"));
|
||||
QCOMPARE(tz2.offsetFromUtc(QDateTime::currentDateTime()), 123456);
|
||||
u"Qt Standard Time"_s);
|
||||
QCOMPARE(tz2.offsetFromUtc(QDateTime::currentDateTime()), 23456);
|
||||
|
||||
// And then with a standard IANA timezone (QTBUG-60595):
|
||||
tz1 = QTimeZone("UTC");
|
||||
@ -1375,16 +1376,17 @@ void tst_QTimeZone::utcTest()
|
||||
QCOMPARE(tz.daylightTimeOffset(now), 0);
|
||||
|
||||
// Test create custom zone
|
||||
tz = QTimeZone("QST", 123456, "Qt Standard Time", "QST", QLocale::Norway, "Qt Testing");
|
||||
tz = QTimeZone("QST"_ba, 23456,
|
||||
u"Qt Standard Time"_s, u"QST"_s, QLocale::Norway, u"Qt Testing"_s);
|
||||
QCOMPARE(tz.isValid(), true);
|
||||
QCOMPARE(tz.id(), QByteArray("QST"));
|
||||
QCOMPARE(tz.comment(), QString("Qt Testing"));
|
||||
QCOMPARE(tz.id(), "QST"_ba);
|
||||
QCOMPARE(tz.comment(), u"Qt Testing"_s);
|
||||
QCOMPARE(tz.territory(), QLocale::Norway);
|
||||
QCOMPARE(tz.abbreviation(now), QString("QST"));
|
||||
QCOMPARE(tz.abbreviation(now), u"QST"_s);
|
||||
QCOMPARE(tz.displayName(QTimeZone::StandardTime, QTimeZone::LongName, QLocale()),
|
||||
QString("Qt Standard Time"));
|
||||
QCOMPARE(tz.offsetFromUtc(now), 123456);
|
||||
QCOMPARE(tz.standardTimeOffset(now), 123456);
|
||||
u"Qt Standard Time"_s);
|
||||
QCOMPARE(tz.offsetFromUtc(now), 23456);
|
||||
QCOMPARE(tz.standardTimeOffset(now), 23456);
|
||||
QCOMPARE(tz.daylightTimeOffset(now), 0);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user