summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2021-02-24 13:30:40 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2021-03-05 16:11:26 +0100
commit33ffc27834759e74fc0446ceb7d26a011dccdf41 (patch)
tree5ddd692305e0510cb70a0e52f1bcb6acc9657e74 /tests
parentbcedeb6d3d8e0e72aac16acbc519d09aa99f23fd (diff)
Add more QDateTime test-cases close to the epoch
The prior tst_QDateTime::setMSecsSinceEpoch(-1) testcase was the last millisecond of 1969; which (deep in the relevant function) actually uses time_t 0 (with the -1 ms offset taken aside to be put back later); so add the matching -1 second test. At the same time, add +1ms and +1s checks for symmetry. Change-Id: Ib487305f6ad81b55563ea59926cae13fb1fde592 Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
index 00ed82ee2d..c2f4e82896 100644
--- a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
@@ -591,10 +591,22 @@ void tst_QDateTime::setMSecsSinceEpoch_data()
<< Q_INT64_C(0)
<< QDateTime(QDate(1970, 1, 1), QTime(0, 0), Qt::UTC)
<< QDateTime(QDate(1970, 1, 1), QTime(1, 0));
- QTest::newRow("-1")
+ QTest::newRow("+1ms")
+ << Q_INT64_C(+1)
+ << QDateTime(QDate(1970, 1, 1), QTime(0, 0, 0, 1), Qt::UTC)
+ << QDateTime(QDate(1970, 1, 1), QTime(1, 0, 0, 1));
+ QTest::newRow("+1s")
+ << Q_INT64_C(+1000)
+ << QDateTime(QDate(1970, 1, 1), QTime(0, 0, 1), Qt::UTC)
+ << QDateTime(QDate(1970, 1, 1), QTime(1, 0, 1));
+ QTest::newRow("-1ms")
<< Q_INT64_C(-1)
<< QDateTime(QDate(1969, 12, 31), QTime(23, 59, 59, 999), Qt::UTC)
<< QDateTime(QDate(1970, 1, 1), QTime(0, 59, 59, 999));
+ QTest::newRow("-1s")
+ << Q_INT64_C(-1000)
+ << QDateTime(QDate(1969, 12, 31), QTime(23, 59, 59), Qt::UTC)
+ << QDateTime(QDate(1970, 1, 1), QTime(0, 59, 59));
QTest::newRow("123456789")
<< Q_INT64_C(123456789)
<< QDateTime(QDate(1970, 1, 2), QTime(10, 17, 36, 789), Qt::UTC)