From fd813f5c3938423137db1fcb02c3c527bd9f58c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Kl=C3=B6cker?= Date: Fri, 10 Jun 2022 12:03:39 +0200 Subject: [PATCH] qt,tests: Allow 1-day-offset for expiration date * lang/qt/tests/t-various.cpp (TestVarious::testSignKeyWithExpiration): Assert that the expiration date is either 2106-02-05 or 2106-02-04. -- This avoids a test failure if the test is run at 00:xx:xx in a location that uses DST. GnuPG-bug-id: 5991 --- lang/qt/tests/t-various.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lang/qt/tests/t-various.cpp b/lang/qt/tests/t-various.cpp index 18360166..336ad34e 100644 --- a/lang/qt/tests/t-various.cpp +++ b/lang/qt/tests/t-various.cpp @@ -337,7 +337,15 @@ private Q_SLOTS: const auto keySignature = target.userID(0).signature(target.userID(0).numSignatures() - 1); QVERIFY(!keySignature.neverExpires()); const auto expirationDate = QDateTime::fromSecsSinceEpoch(uint_least32_t(keySignature.expirationTime())).date(); - QCOMPARE(expirationDate, QDate(2106, 2, 5)); // expiration date is capped at 2106-02-05 + // expiration date is capped at 2106-02-05; we also allow 2106-02-04 as expiration date because for locations that use DST + // the expiration date may be 2106-02-04-23:xx:xx (in local non-DST time) if the current time is 00:xx::xx (in local DST time) + const auto expectedExpirationRange = std::make_pair(QDate{2106, 2, 4}, QDate{2106, 2, 5}); + QVERIFY2(expirationDate >= expectedExpirationRange.first, + ("\n Actual : " + expirationDate.toString(Qt::ISODate).toLatin1() + + "\n Expected: " + expectedExpirationRange.first.toString(Qt::ISODate).toLatin1()).constData()); + QVERIFY2(expirationDate <= expectedExpirationRange.second, + ("\n Actual : " + expirationDate.toString(Qt::ISODate).toLatin1() + + "\n Expected: " + expectedExpirationRange.second.toString(Qt::ISODate).toLatin1()).constData()); } void testVersion() -- 2.37.1