7aed4171dc
Update gpgme to 1.17.1 (fix libqpgpme ABI, #2127553) Prepare for distutils drop in Python 3.12+ (#2135758) Fix tests on 32-bit machines (#2096365) Use SPDX syntax for License field Add option to not build Qt binding (qgpgme)
160 lines
8.5 KiB
Diff
160 lines
8.5 KiB
Diff
From f2b48de26b8f8c48c293423eda712831544924f6 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Ingo=20Kl=C3=B6cker?= <dev@ingo-kloecker.de>
|
|
Date: Wed, 17 Aug 2022 15:22:29 +0200
|
|
Subject: [PATCH] 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
|
|
---
|
|
lang/qt/tests/t-addexistingsubkey.cpp | 6 +++---
|
|
lang/qt/tests/t-changeexpiryjob.cpp | 26 +++++++++++++-------------
|
|
2 files changed, 16 insertions(+), 16 deletions(-)
|
|
|
|
diff --git a/lang/qt/tests/t-addexistingsubkey.cpp b/lang/qt/tests/t-addexistingsubkey.cpp
|
|
index 2e654cec..87eadf43 100644
|
|
--- a/lang/qt/tests/t-addexistingsubkey.cpp
|
|
+++ b/lang/qt/tests/t-addexistingsubkey.cpp
|
|
@@ -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());
|
|
diff --git a/lang/qt/tests/t-changeexpiryjob.cpp b/lang/qt/tests/t-changeexpiryjob.cpp
|
|
index 090002f3..3da74d46 100644
|
|
--- a/lang/qt/tests/t-changeexpiryjob.cpp
|
|
+++ b/lang/qt/tests/t-changeexpiryjob.cpp
|
|
@@ -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());
|
|
--
|
|
2.37.1
|
|
|