qt,tests: Make test pass on 32-bit systems

* lang/qt/tests/t-addexistingsubkey.cpp
(AddExistingSubkeyJobTest::testAddExistingSubkeyWithExpiration): Handle
negative expiration date.
--

On 32-bit systems the expiration date of the test key overflows. This
will cause the AddExistingSubkeyJob to fail. We expect it to fail with
an "invalid time" error.

GnuPG-bug-id: 6137
This commit is contained in:
Ingo Klöcker 2022-08-18 10:55:09 +02:00
parent 2fa5c80aeb
commit 2e7a61b898

View File

@ -213,6 +213,7 @@ private Q_SLOTS:
const auto result = job->exec(key, sourceSubkey); const auto result = job->exec(key, sourceSubkey);
if (sourceSubkey.expirationTime() > 0) {
QCOMPARE(result.code(), static_cast<int>(GPG_ERR_NO_ERROR)); QCOMPARE(result.code(), static_cast<int>(GPG_ERR_NO_ERROR));
key.update(); key.update();
QCOMPARE(key.numSubkeys(), 3u); QCOMPARE(key.numSubkeys(), 3u);
@ -231,6 +232,11 @@ private Q_SLOTS:
QVERIFY2(actualExpiration <= expectedExpirationRange.second, QVERIFY2(actualExpiration <= expectedExpirationRange.second,
("actual: " + std::to_string(actualExpiration) + ("actual: " + std::to_string(actualExpiration) +
"; expected: " + std::to_string(expectedExpirationRange.second)).c_str()); "; expected: " + std::to_string(expectedExpirationRange.second)).c_str());
} else {
// on 32-bit systems the expiration date of the test key overflows;
// in this case we expect an appropriate error code
QCOMPARE(result.code(), static_cast<int>(GPG_ERR_INV_TIME));
}
} }
private: private: