From 9aa87643d7b361e5df78727e0579c2991a5fda61 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 24 Mar 2023 13:43:08 +0100 Subject: [PATCH] tst_QDate::startOfDay_endOfDay(): rename variables, add comments The name final is suboptimal, given that it's also a keyword. Rename initial at the same time. The local-time parts of the test are apt to fail if local time coincides with the zone being tested, as previously noted. Document known cases of such coincidences, to help someone studying a failure to know why it happened. Change-Id: I1f1f302f161373a154066df210e03725b9a5f9ed Reviewed-by: Thiago Macieira --- tests/auto/corelib/time/qdate/tst_qdate.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/auto/corelib/time/qdate/tst_qdate.cpp b/tests/auto/corelib/time/qdate/tst_qdate.cpp index 30dc455dd3..dd05f001f8 100644 --- a/tests/auto/corelib/time/qdate/tst_qdate.cpp +++ b/tests/auto/corelib/time/qdate/tst_qdate.cpp @@ -498,22 +498,29 @@ void tst_QDate::startOfDay_endOfDay_data() QTest::addColumn("start"); QTest::addColumn("end"); - const QTime initial(0, 0), final(23, 59, 59, 999), invalid(QDateTime().time()); + const QTime early(0, 0), late(23, 59, 59, 999), invalid(QDateTime().time()); // UTC is always a valid zone. QTest::newRow("epoch") << epochDate() << QByteArray("UTC") - << initial << final; + << early << late; if (QTimeZone("America/Sao_Paulo").isValid()) { QTest::newRow("Brazil") << QDate(2008, 10, 19) << QByteArray("America/Sao_Paulo") - << QTime(1, 0) << final; + << QTime(1, 0) << late; + // Several South American zones coincide, see + // tst_QDateTime::fromStringDateFormat(ISO 24:00 in DST). } #if QT_CONFIG(icu) || !defined(Q_OS_WIN) // MS's TZ APIs lack data if (QTimeZone("Europe/Sofia").isValid()) { + // Several southern zones within EET (but not the northern ones) spent + // part of the 1990s using midnight as spring transition. These included + // Asia/{Beirut,Famagusta,Nicosia} and Europe/{Bucharest,Chisinau,Nicosia}. QTest::newRow("Sofia") << QDate(1994, 3, 27) << QByteArray("Europe/Sofia") - << QTime(1, 0) << final; + << QTime(1, 0) << late; + // Additionally, America/Scoresbysund, Atlantic/Azores, + // Asia/{Choibalsan,Hovd,Tbilisi,Ulan_Bator,Ulaanbaatar} coincide. } #endif if (QTimeZone("Pacific/Kiritimati").isValid()) { @@ -564,6 +571,7 @@ void tst_QDate::startOfDay_endOfDay() if (!isSystem) { // These might fail if system zone coincides with zone; but only if it // did something similarly unusual on the date picked for this test. + // See comments on test cases. if (start.isValid()) { QCOMPARE(front.date(), date); QCOMPARE(front.time(), QTime(0, 0));