diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-03-31 15:59:14 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-03-31 18:26:02 +0200 |
commit | 73dd16dbb28bb5c55d1fbdf6c6ef57dbe93a7de6 (patch) | |
tree | 892eaa59edec7a1627969fc849bd2eeb43d77321 /openpgp/src/types/server_preferences.rs | |
parent | fab2a27aaf99a6e05057e8aaea6c5d0a949dca92 (diff) |
openpgp: Implement Arbitrary for the bit field types.
Diffstat (limited to 'openpgp/src/types/server_preferences.rs')
-rw-r--r-- | openpgp/src/types/server_preferences.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/openpgp/src/types/server_preferences.rs b/openpgp/src/types/server_preferences.rs index 9578130f..d6a0b7f2 100644 --- a/openpgp/src/types/server_preferences.rs +++ b/openpgp/src/types/server_preferences.rs @@ -1,5 +1,6 @@ use std::hash::{Hash, Hasher}; use std::fmt; +use quickcheck::{Arbitrary, Gen}; /// Describes preferences regarding key servers. /// @@ -130,6 +131,12 @@ const KEYSERVER_PREFERENCE_NO_MODIFY: u8 = 0x80; /// Number of bytes with known flags. const KEYSERVER_PREFERENCES_N_KNOWN_BYTES: usize = 1; +impl Arbitrary for KeyServerPreferences { + fn arbitrary<G: Gen>(g: &mut G) -> Self { + Self::new(Vec::arbitrary(g)) + } +} + #[cfg(test)] mod tests { use super::*; @@ -146,9 +153,9 @@ mod tests { } quickcheck! { - fn roundtrip(raw: Vec<u8>) -> bool { - let val = KeyServerPreferences::new(&raw); - assert_eq!(raw, val.to_vec()); + fn roundtrip(val: KeyServerPreferences) -> bool { + let q = KeyServerPreferences::new(&val.to_vec()); + assert_eq!(val, q); // Check that equality ignores padding. let mut val_without_padding = val.clone(); |