Add explicit test coverage for QTimezone::utc
Basically this should work exactly the same as constructing the QUtcTimeZonePrivate directly. Follow-up performance optimizations should not change any of this behavior. Pick-to: 6.9 6.8 6.5 5.15 Change-Id: I2a3e78965f3a553b8b70cb12f7772b9fdfbf7bf7 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
parent
6626874286
commit
7a79ce13a9
@ -1327,9 +1327,22 @@ void tst_QTimeZone::utcTest()
|
||||
QCOMPARE(tzp.hasDaylightTime(), false);
|
||||
QCOMPARE(tzp.hasTransitions(), false);
|
||||
|
||||
// Test UTC accessor
|
||||
const QDateTime now = QDateTime::currentDateTime();
|
||||
auto tz = QTimeZone::utc();
|
||||
QCOMPARE(tz.isValid(), true);
|
||||
QCOMPARE(tz.id(), QByteArrayLiteral("UTC"));
|
||||
QCOMPARE(tz.territory(), QLocale::AnyTerritory);
|
||||
QCOMPARE(tz.abbreviation(now), QStringLiteral("UTC"));
|
||||
QCOMPARE(tz.displayName(QTimeZone::StandardTime, QTimeZone::LongName, QLocale()), QStringLiteral("UTC"));
|
||||
QCOMPARE(tz.offsetFromUtc(now), 0);
|
||||
QCOMPARE(tz.standardTimeOffset(now), 0);
|
||||
QCOMPARE(tz.daylightTimeOffset(now), 0);
|
||||
QCOMPARE(tz.hasDaylightTime(), false);
|
||||
QCOMPARE(tz.hasTransitions(), false);
|
||||
|
||||
// Test create from UTC Offset:
|
||||
QDateTime now = QDateTime::currentDateTime();
|
||||
QTimeZone tz(36000);
|
||||
tz = QTimeZone(36000);
|
||||
QVERIFY(tz.isValid());
|
||||
QCOMPARE(tz.id(), QByteArray("UTC+10:00"));
|
||||
QCOMPARE(tz.offsetFromUtc(now), 36000);
|
||||
|
Loading…
x
Reference in New Issue
Block a user