From f0333355dd369394025c85c55d4c90483c892135 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 17 Feb 2022 11:30:24 +0100 Subject: [PATCH] Add tests for an assertion seen on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QDateTimeEdit's default constructor instantiates the start of 1752-09-14 as its default earliest time; however Friedeman has seen this triggering an assertion. The QDTE tests should be picking that up anyway, but let's overtly test it in QDate's startOfDay testing, too. Change-Id: Ifae87f2695ac3a7993c173a7c21809c87d5daa71 Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Qt CI Bot --- tests/auto/corelib/time/qdate/tst_qdate.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/auto/corelib/time/qdate/tst_qdate.cpp b/tests/auto/corelib/time/qdate/tst_qdate.cpp index 4a5725c42e4..590bbc2d327 100644 --- a/tests/auto/corelib/time/qdate/tst_qdate.cpp +++ b/tests/auto/corelib/time/qdate/tst_qdate.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2021 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Copyright (C) 2016 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** @@ -641,6 +641,17 @@ void tst_QDate::startOfDay_endOfDay_bounds() QCOMPARE(last.date().startOfDay(Qt::UTC).time(), QTime(0, 0)); QVERIFY(!first.date().startOfDay(Qt::UTC).isValid()); QVERIFY(!last.date().endOfDay(Qt::UTC).isValid()); + + // Test for QTBUG-100873, shouldn't assert: + const QDate qdteMin(1752, 9, 14); // Used by QDateTimeEdit + QCOMPARE(qdteMin.startOfDay(Qt::UTC).date(), qdteMin); + QCOMPARE(qdteMin.startOfDay(Qt::LocalTime).date(), qdteMin); +#if QT_CONFIG(timezone) + QCOMPARE(qdteMin.startOfDay(QTimeZone::systemTimeZone()).date(), qdteMin); + QTimeZone berlin("Europe/Berlin"); + if (berlin.isValid()) + QCOMPARE(qdteMin.startOfDay(berlin).date(), qdteMin); +#endif } void tst_QDate::julianDaysLimits()