Skip a date-time test when we don't know what result it should give

The operator_eqeq(data13) test expected the local-time epoch and UTC
epoch to agree precisely if the localTimeType set by the test's
constructor says local time is UTC; however, when the local zone is
*sometimes* ahead of (or behind) UTC, due to DST, localTimeType is
duly set to indicate that, which doesn't preclude the zone agreeing
with UTC at the epoch.  This indeed happens for Europe/London, which
agrees on the epoch but was ahead a few months later.  So we can't
determine what outcome to expect based solely on localTimeType,
although we can be sure of a match when local time is UTC.  So skip
this test when local time isn't UTC (and document what's going on a
bit better).

Task-number: QTBUG-65435
Change-Id: Id9b8aa0402f2a2b410e0234f6eca4ab0d1010bc4
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Edward Welbourne 2018-01-09 19:23:57 +01:00
parent f13b0b2cf2
commit f4436276d9
1 changed files with 7 additions and 5 deletions

View File

@ -1912,7 +1912,7 @@ void tst_QDateTime::operator_eqeq_data()
QDateTime dateTime1a = dateTime1.addMSecs(1);
QDateTime dateTime2(QDate(2012, 20, 6), QTime(14, 33, 2, 500));
QDateTime dateTime2a = dateTime2.addMSecs(-1);
QDateTime dateTime3(QDate(1970, 1, 1), QTime(0, 0, 0, 0), Qt::UTC);
QDateTime dateTime3(QDate(1970, 1, 1), QTime(0, 0, 0, 0), Qt::UTC); // UTC epoch
QDateTime dateTime3a = dateTime3.addDays(1);
QDateTime dateTime3b = dateTime3.addDays(-1);
// Ensure that different times may be equal when considering timezone.
@ -1920,8 +1920,7 @@ void tst_QDateTime::operator_eqeq_data()
dateTime3c.setOffsetFromUtc(3600);
QDateTime dateTime3d(dateTime3.addSecs(-3600));
dateTime3d.setOffsetFromUtc(-3600);
// Convert from UTC to local.
QDateTime dateTime3e(dateTime3.date(), dateTime3.time());
QDateTime dateTime3e(dateTime3.date(), dateTime3.time()); // Local time's epoch
QTest::newRow("data0") << dateTime1 << dateTime1 << true << false;
QTest::newRow("data1") << dateTime2 << dateTime2 << true << false;
@ -1936,8 +1935,11 @@ void tst_QDateTime::operator_eqeq_data()
QTest::newRow("data10") << dateTime3 << dateTime3c << true << false;
QTest::newRow("data11") << dateTime3 << dateTime3d << true << false;
QTest::newRow("data12") << dateTime3c << dateTime3d << true << false;
QTest::newRow("data13") << dateTime3 << dateTime3e
<< (localTimeType == LocalTimeIsUtc) << false;
if (localTimeType == LocalTimeIsUtc)
QTest::newRow("data13") << dateTime3 << dateTime3e << true << false;
// ... but a zone (sometimes) ahead of or behind UTC (e.g. Europe/London)
// might agree with UTC about the epoch, all the same.
QTest::newRow("invalid == invalid") << invalidDateTime() << invalidDateTime() << true << false;
QTest::newRow("invalid == valid #1") << invalidDateTime() << dateTime1 << false << false;