diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2022-01-12 19:41:51 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-02-09 14:56:10 +0000 |
commit | bb21bc23b72b6109bfa4c9fde06caaca215347a7 (patch) | |
tree | 8402f82d283e5a8aa725155b95ad235e034fbcf2 /tests | |
parent | ec0a5d1574daecc0a840c10f8734d0e859d47d2e (diff) |
Add some more QDate::{start,end}OfDay() tests
While investigating an assertion failure I noticed that the existing
tests didn't even exercise these methods for local time or zone time.
Of course, we can't robustly test these time-specs, due to vagueries
of offset details and zone availability, but we can at least verify
that they return date-times on the specified date. Add a test-case for
the start of 1900, on which the assertions were first seen; it is the
earliest moment representable with tm_year >= 0, after all.
One of these tests fails on 6.2 but the fix for that (as opposed to
the the assertion) requires 6.3's improvements to the handling of
time_t's fuller range - too risky a change to pick back to 6.2.
Task-number: QTBUG-99747
Change-Id: I98f5d7850a701972b2d8ea2ce203a2b3e7071354
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 830fd1908ba14d434d1715304a430b62d0281eee)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/time/qdate/tst_qdate.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/auto/corelib/time/qdate/tst_qdate.cpp b/tests/auto/corelib/time/qdate/tst_qdate.cpp index 911ad90a7a..4a5725c42e 100644 --- a/tests/auto/corelib/time/qdate/tst_qdate.cpp +++ b/tests/auto/corelib/time/qdate/tst_qdate.cpp @@ -568,6 +568,7 @@ void tst_QDate::startOfDay_endOfDay_fixed_data() } data[] = { { "epoch", QDate(1970, 1, 1) }, { "y2k-leap-day", QDate(2000, 2, 29) }, + { "start-1900", QDate(1900, 1, 1) }, // QTBUG-99747 // Just outside the start and end of 32-bit time_t: { "pre-sign32", QDate(start32sign.date().year(), 1, 1) }, { "post-sign32", QDate(end32sign.date().year(), 12, 31) }, @@ -605,6 +606,17 @@ void tst_QDate::startOfDay_endOfDay_fixed() QCOMPARE(date.addDays(1).startOfDay(Qt::OffsetFromUTC, offset).addMSecs(-1), end); QCOMPARE(date.addDays(-1).endOfDay(Qt::OffsetFromUTC, offset).addMSecs(1), start); } + + // Minimal testing for LocalTime and TimeZone + QCOMPARE(date.startOfDay(Qt::LocalTime).date(), date); + QCOMPARE(date.endOfDay(Qt::LocalTime).date(), date); +#if QT_CONFIG(timezone) + const QTimeZone cet("Europe/Oslo"); + if (cet.isValid()) { + QCOMPARE(date.startOfDay(cet).date(), date); + QCOMPARE(date.endOfDay(cet).date(), date); + } +#endif } void tst_QDate::startOfDay_endOfDay_bounds() |