summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNora Widdecke <nora@sequoia-pgp.org>2021-03-25 17:19:15 +0100
committerNora Widdecke <nora@sequoia-pgp.org>2021-03-25 17:19:15 +0100
commitfc8663a80699bd0dc69059a4c6a3c9a6b23f631a (patch)
tree6f33ebfc31b7221df9bda372b3bd7d67fbc19f55
parentf42e55194eac54763ba8e197c94a6e2d6d563d3c (diff)
openpgp: Check size of SystemTime.merge-requests/1049
- Gating the 32-bit SystemTime test on the target platform may be incorrect. Instead, check the size of SystemTime.
-rw-r--r--openpgp/src/types/timestamp.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/openpgp/src/types/timestamp.rs b/openpgp/src/types/timestamp.rs
index af318c29..fc915497 100644
--- a/openpgp/src/types/timestamp.rs
+++ b/openpgp/src/types/timestamp.rs
@@ -669,15 +669,20 @@ mod tests {
}
// #668
- // Ensure that, on 32-bit platforms, Timestamps between i32::MAX + 1 and u32::MAX are
- // clamped down to i32::MAX, and values below are not altered.
- #[cfg(any(target_arch = "x86", target_arch = "arm", target_arch = "mips"))]
+ // Ensure that, on systems with a 32-bit time_t, Timestamps between
+ // i32::MAX + 1 and u32::MAX are clamped down to i32::MAX, and values
+ // below are not altered.
#[test]
fn system_time_32_bit() -> Result<()> {
+ if std::mem::size_of::<SystemTime>() != 32 {
+ return Ok(())
+ }
+
let t1 = Timestamp::from(u32::MAX);
- let t2 = Timestamp::from(i32::MAX as u32 + 1);
assert_eq!(SystemTime::from(t1),
UNIX_EPOCH + SystemDuration::new(i32::MAX as u64, 0));
+
+ let t2 = Timestamp::from(i32::MAX as u32 + 1);
assert_eq!(SystemTime::from(t2),
UNIX_EPOCH + SystemDuration::new(i32::MAX as u64, 0));