From 06e2719f730e4545d370f7d7dabb32a24247e6c8 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 25 Apr 2023 16:40:10 +0200 Subject: [PATCH] Add test-cases for QDate::{start,end}OfDay() at QDateTime's bounds Task-number: QTBUG-68855 Change-Id: Ic91cb5f9947ce5ee533fc77ae24a50376e139ab3 Reviewed-by: Thiago Macieira --- tests/auto/corelib/time/qdate/tst_qdate.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/auto/corelib/time/qdate/tst_qdate.cpp b/tests/auto/corelib/time/qdate/tst_qdate.cpp index 6be26bed799..ab6b8a53a98 100644 --- a/tests/auto/corelib/time/qdate/tst_qdate.cpp +++ b/tests/auto/corelib/time/qdate/tst_qdate.cpp @@ -518,9 +518,20 @@ void tst_QDate::startOfDay_endOfDay_data() constexpr MsKludges IgnoreBoth = IgnoreStart | IgnoreEnd; const QTimeZone UTC(QTimeZone::UTC); + using Bound = std::numeric_limits; + const auto dateAtMillis = [UTC](qint64 millis) { + return QDateTime::fromMSecsSinceEpoch(millis, UTC).date(); + }; + // UTC and fixed offset are always available and predictable: QTest::newRow("epoch") << epochDate() << UTC << early << late << MsKludges{}; + // First and last days in QDateTime's supported range: + QTest::newRow("earliest") + << dateAtMillis(Bound::min()) << UTC << invalid << late << MsKludges{}; + QTest::newRow("latest") + << dateAtMillis(Bound::max()) << UTC << early << invalid << MsKludges{}; + const struct { const char *test; const char *zone;