summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2021-02-09 16:29:00 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2021-02-11 11:46:04 +0100
commit9bc849f9c4fe921763859d9c8f363563d6a59548 (patch)
treee8a433c736d24d306b8a7c4771a7e3968fa2c625 /tests/auto
parent85c7a9d3a6710f8487ce4aa1e4e2d7d1d46b6cde (diff)
Make QDate's text round-trip test do actual comparisons
Previously the only test was that it produced no warnings, if anyone paused to read the output to notice them. Change-Id: I225ca99c7ec316186702c0fdb355585374c014a4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/time/qdate/tst_qdate.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/tests/auto/corelib/time/qdate/tst_qdate.cpp b/tests/auto/corelib/time/qdate/tst_qdate.cpp
index 53cb70403c..6f8699bc98 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) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Copyright (C) 2016 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
@@ -1542,11 +1542,13 @@ void tst_QDate::printNegativeYear() const
void tst_QDate::roundtripString() const
{
/* This code path should not result in warnings. */
- const QDate theDate(QDate::currentDate());
- theDate.fromString(theDate.toString(Qt::TextDate), Qt::TextDate);
+ const QDate date(QDate::currentDate());
+ QCOMPARE(date.fromString(date.toString(Qt::TextDate), Qt::TextDate), date);
- const QDateTime theDateTime(QDateTime::currentDateTime());
- theDateTime.fromString(theDateTime.toString(Qt::TextDate), Qt::TextDate);
+ const QDateTime now(QDateTime::currentDateTime());
+ // TextDate discards milliseconds, so clip to whole second:
+ const QDateTime when = now.addMSecs(-now.time().msec());
+ QCOMPARE(when.fromString(when.toString(Qt::TextDate), Qt::TextDate), when);
}
#endif