qt,tests: Make sure expiration time is interpreted as unsigned number
* lang/qt/tests/t-addexistingsubkey.cpp, lang/qt/tests/t-changeexpiryjob.cpp: Convert expiration time to uint_least32_t. -- This doesn't change the outcome of the tests (they also pass without this change because of the expiration dates of the test keys), but it's still good practise to treat the expiration time as an unsigned number if the assertions check that the expiration time is in some range. GnuPG-bug-id: 6137
This commit is contained in:
parent
81d4b7f2d7
commit
f2b48de26b
@ -222,9 +222,9 @@ private Q_SLOTS:
|
||||
// several times
|
||||
const auto allowedDeltaTSeconds = 1;
|
||||
const auto expectedExpirationRange = std::make_pair(
|
||||
sourceSubkey.expirationTime() - allowedDeltaTSeconds,
|
||||
sourceSubkey.expirationTime() + allowedDeltaTSeconds);
|
||||
const auto actualExpiration = key.subkey(2).expirationTime();
|
||||
uint_least32_t(sourceSubkey.expirationTime()) - allowedDeltaTSeconds,
|
||||
uint_least32_t(sourceSubkey.expirationTime()) + allowedDeltaTSeconds);
|
||||
const auto actualExpiration = uint_least32_t(key.subkey(2).expirationTime());
|
||||
QVERIFY2(actualExpiration >= expectedExpirationRange.first,
|
||||
("actual: " + std::to_string(actualExpiration) +
|
||||
"; expected: " + std::to_string(expectedExpirationRange.first)).c_str());
|
||||
|
@ -70,7 +70,7 @@ private Q_SLOTS:
|
||||
QVERIFY(!key.isNull());
|
||||
QVERIFY(!key.subkey(0).isNull());
|
||||
QVERIFY(!key.subkey(1).isNull());
|
||||
const auto subkeyExpiration = key.subkey(1).expirationTime();
|
||||
const auto subkeyExpiration = uint_least32_t(key.subkey(1).expirationTime());
|
||||
|
||||
{
|
||||
// Create the job
|
||||
@ -101,7 +101,7 @@ private Q_SLOTS:
|
||||
newExpirationDate.toSecsSinceEpoch() - 10,
|
||||
QDateTime::currentDateTime().addDays(1).toSecsSinceEpoch());
|
||||
{
|
||||
const auto actualExpiration = key.subkey(0).expirationTime();
|
||||
const auto actualExpiration = uint_least32_t(key.subkey(0).expirationTime());
|
||||
QVERIFY2(actualExpiration >= expectedExpirationRange.first,
|
||||
("actual: " + std::to_string(actualExpiration) +
|
||||
"; expected: " + std::to_string(expectedExpirationRange.first)).c_str());
|
||||
@ -110,7 +110,7 @@ private Q_SLOTS:
|
||||
"; expected: " + std::to_string(expectedExpirationRange.second)).c_str());
|
||||
}
|
||||
{
|
||||
const auto actualExpiration = key.subkey(1).expirationTime();
|
||||
const auto actualExpiration = uint_least32_t(key.subkey(1).expirationTime());
|
||||
QCOMPARE(actualExpiration, subkeyExpiration); // unchanged
|
||||
}
|
||||
}
|
||||
@ -133,7 +133,7 @@ private Q_SLOTS:
|
||||
QVERIFY(!key.isNull());
|
||||
QVERIFY(!key.subkey(0).isNull());
|
||||
QVERIFY(!key.subkey(1).isNull());
|
||||
const auto primaryKeyExpiration = key.subkey(0).expirationTime();
|
||||
const auto primaryKeyExpiration = uint_least32_t(key.subkey(0).expirationTime());
|
||||
|
||||
{
|
||||
// Create the job
|
||||
@ -164,11 +164,11 @@ private Q_SLOTS:
|
||||
newExpirationDate.toSecsSinceEpoch() - 10,
|
||||
QDateTime::currentDateTime().addDays(2).toSecsSinceEpoch());
|
||||
{
|
||||
const auto actualExpiration = key.subkey(0).expirationTime();
|
||||
const auto actualExpiration = uint_least32_t(key.subkey(0).expirationTime());
|
||||
QCOMPARE(actualExpiration, primaryKeyExpiration); // unchanged
|
||||
}
|
||||
{
|
||||
const auto actualExpiration = key.subkey(1).expirationTime();
|
||||
const auto actualExpiration = uint_least32_t(key.subkey(1).expirationTime());
|
||||
QVERIFY2(actualExpiration >= expectedExpirationRange.first,
|
||||
("actual: " + std::to_string(actualExpiration) +
|
||||
"; expected: " + std::to_string(expectedExpirationRange.first)).c_str());
|
||||
@ -196,7 +196,7 @@ private Q_SLOTS:
|
||||
QVERIFY(!key.isNull());
|
||||
QVERIFY(!key.subkey(0).isNull());
|
||||
QVERIFY(!key.subkey(1).isNull());
|
||||
const auto subkeyExpiration = key.subkey(1).expirationTime();
|
||||
const auto subkeyExpiration = uint_least32_t(key.subkey(1).expirationTime());
|
||||
|
||||
{
|
||||
// Create the job
|
||||
@ -228,7 +228,7 @@ private Q_SLOTS:
|
||||
newExpirationDate.toSecsSinceEpoch() - 10,
|
||||
QDateTime::currentDateTime().addDays(3).toSecsSinceEpoch());
|
||||
{
|
||||
const auto actualExpiration = key.subkey(0).expirationTime();
|
||||
const auto actualExpiration = uint_least32_t(key.subkey(0).expirationTime());
|
||||
QVERIFY2(actualExpiration >= expectedExpirationRange.first,
|
||||
("actual: " + std::to_string(actualExpiration) +
|
||||
"; expected: " + std::to_string(expectedExpirationRange.first)).c_str());
|
||||
@ -237,7 +237,7 @@ private Q_SLOTS:
|
||||
"; expected: " + std::to_string(expectedExpirationRange.second)).c_str());
|
||||
}
|
||||
{
|
||||
const auto actualExpiration = key.subkey(1).expirationTime();
|
||||
const auto actualExpiration = uint_least32_t(key.subkey(1).expirationTime());
|
||||
QCOMPARE(actualExpiration, subkeyExpiration); // unchanged
|
||||
}
|
||||
}
|
||||
@ -291,7 +291,7 @@ private Q_SLOTS:
|
||||
newExpirationDate.toSecsSinceEpoch() - 10,
|
||||
QDateTime::currentDateTime().addDays(4).toSecsSinceEpoch());
|
||||
{
|
||||
const auto actualExpiration = key.subkey(0).expirationTime();
|
||||
const auto actualExpiration = uint_least32_t(key.subkey(0).expirationTime());
|
||||
QVERIFY2(actualExpiration >= expectedExpirationRange.first,
|
||||
("actual: " + std::to_string(actualExpiration) +
|
||||
"; expected: " + std::to_string(expectedExpirationRange.first)).c_str());
|
||||
@ -300,7 +300,7 @@ private Q_SLOTS:
|
||||
"; expected: " + std::to_string(expectedExpirationRange.second)).c_str());
|
||||
}
|
||||
{
|
||||
const auto actualExpiration = key.subkey(1).expirationTime();
|
||||
const auto actualExpiration = uint_least32_t(key.subkey(1).expirationTime());
|
||||
QVERIFY2(actualExpiration >= expectedExpirationRange.first,
|
||||
("actual: " + std::to_string(actualExpiration) +
|
||||
"; expected: " + std::to_string(expectedExpirationRange.first)).c_str());
|
||||
@ -359,7 +359,7 @@ private Q_SLOTS:
|
||||
newExpirationDate.toSecsSinceEpoch() - 10,
|
||||
QDateTime::currentDateTime().addDays(5).toSecsSinceEpoch());
|
||||
{
|
||||
const auto actualExpiration = key.subkey(0).expirationTime();
|
||||
const auto actualExpiration = uint_least32_t(key.subkey(0).expirationTime());
|
||||
QVERIFY2(actualExpiration >= expectedExpirationRange.first,
|
||||
("actual: " + std::to_string(actualExpiration) +
|
||||
"; expected: " + std::to_string(expectedExpirationRange.first)).c_str());
|
||||
@ -368,7 +368,7 @@ private Q_SLOTS:
|
||||
"; expected: " + std::to_string(expectedExpirationRange.second)).c_str());
|
||||
}
|
||||
{
|
||||
const auto actualExpiration = key.subkey(1).expirationTime();
|
||||
const auto actualExpiration = uint_least32_t(key.subkey(1).expirationTime());
|
||||
QVERIFY2(actualExpiration >= expectedExpirationRange.first,
|
||||
("actual: " + std::to_string(actualExpiration) +
|
||||
"; expected: " + std::to_string(expectedExpirationRange.first)).c_str());
|
||||
|
Loading…
Reference in New Issue
Block a user