diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2020-09-21 11:06:18 +0200 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2020-09-23 14:59:08 +0000 |
commit | 3bd6901429611636d254bb0140799b019112985d (patch) | |
tree | d11ae361d1d8c019cd7a0ccf1e996c74bb50ad14 /tests | |
parent | 691762e0e36558257291677d3458628558b380f5 (diff) |
Use same-msecs optimization more in QDateTime comparison
QDateTime's comparisons just compare milliseconds when both values are
local times and their statuses (hence DST-ness) match. It can do the
same for time-zones. While doing the same for UTC and fixed offsets
wins nothing, it also costs nothing, given that we're already checking
the spec.
Task-number: QTBUG-75585
Change-Id: Ib6d824569aba8def2f1319ef3a11cca6869a5b5e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp index b942316c95..a568ef69db 100644 --- a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp @@ -1971,12 +1971,26 @@ void tst_QDateTime::operator_eqeq_data() // might agree with UTC about the epoch, all the same. QTest::newRow("invalid == invalid") << QDateTime() << QDateTime() << true << false; - QTest::newRow("invalid == valid #1") << QDateTime() << dateTime1 << false << false; + QTest::newRow("invalid != valid #1") << QDateTime() << dateTime1 << false << false; if (zoneIsCET) { - QTest::newRow("data14") << QDateTime(QDate(2004, 1, 2), QTime(2, 2, 3), Qt::LocalTime) - << QDateTime(QDate(2004, 1, 2), QTime(1, 2, 3), Qt::UTC) << true << true; + QTest::newRow("data14") + << QDateTime(QDate(2004, 1, 2), QTime(2, 2, 3), Qt::LocalTime) + << QDateTime(QDate(2004, 1, 2), QTime(1, 2, 3), Qt::UTC) << true << true; + QTest::newRow("local-fall-back") // Sun, 31 Oct 2004, 02:30, both ways round: + << QDateTime::fromMSecsSinceEpoch(Q_INT64_C(1099186200000)) + << QDateTime::fromMSecsSinceEpoch(Q_INT64_C(1099182600000)) + << false << false; } +#if QT_CONFIG(timezone) + const QTimeZone CET("Europe/Oslo"); + if (CET.isValid()) { + QTest::newRow("CET-fall-back") // Sun, 31 Oct 2004, 02:30, both ways round: + << QDateTime::fromMSecsSinceEpoch(Q_INT64_C(1099186200000), CET) + << QDateTime::fromMSecsSinceEpoch(Q_INT64_C(1099182600000), CET) + << false << false; + } +#endif } void tst_QDateTime::operator_eqeq() |