summaryrefslogtreecommitdiffstats
path: root/openpgp/src/types/timestamp.rs
diff options
context:
space:
mode:
authorNora Widdecke <nora@sequoia-pgp.org>2021-12-03 11:45:55 +0100
committerNora Widdecke <nora@sequoia-pgp.org>2021-12-13 19:01:14 +0100
commita79a35952cb2cf92bd6ba60fa7df057fb2eae1d2 (patch)
treebbc0e2be95ddcf580e8725905381f518db744afc /openpgp/src/types/timestamp.rs
parentf8cf8a339d08f04c0078eedca080896d318f35fd (diff)
openpgp: Fix duration_round_up test.
- If the round_up clampes the value to u32::MAX, the precision does not apply. - Closes #784.
Diffstat (limited to 'openpgp/src/types/timestamp.rs')
-rw-r--r--openpgp/src/types/timestamp.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/openpgp/src/types/timestamp.rs b/openpgp/src/types/timestamp.rs
index aa0341a5..284b6ec9 100644
--- a/openpgp/src/types/timestamp.rs
+++ b/openpgp/src/types/timestamp.rs
@@ -655,7 +655,9 @@ mod tests {
fn duration_round_up(d: Duration) -> bool {
let u = d.round_up(None, None).unwrap();
assert!(d <= u);
- assert_eq!(u32::from(u) & 0b1_1111_1111_1111_1111_1111, 0);
+ assert!(u32::from(u) & 0b1_1111_1111_1111_1111_1111 == 0
+ || u32::from(u) == u32::MAX
+ );
assert!(u32::from(u) - u32::from(d) < 2_u32.pow(21));
true
}