diff options
author | Nora Widdecke <nora@sequoia-pgp.org> | 2021-07-26 12:28:29 +0200 |
---|---|---|
committer | Nora Widdecke <nora@sequoia-pgp.org> | 2021-12-13 19:01:14 +0100 |
commit | 321b0cc381f3c44f81cfc4a9cf502be169262d14 (patch) | |
tree | 20c5ee6c7a551872a5037d89331b642e6190f4a8 /openpgp/src/types | |
parent | a79a35952cb2cf92bd6ba60fa7df057fb2eae1d2 (diff) |
ipc, openpgp: Bump quickcheck to 1.0.3.
- Adapt to the new API:
- Gen is now a struct, not a Trait, and replaces StdThreadGen.
- The rand re-export has been removed. As a consequence, we need
our own function to generate an arbitrary value from a range.
Diffstat (limited to 'openpgp/src/types')
-rw-r--r-- | openpgp/src/types/features.rs | 2 | ||||
-rw-r--r-- | openpgp/src/types/key_flags.rs | 2 | ||||
-rw-r--r-- | openpgp/src/types/mod.rs | 33 | ||||
-rw-r--r-- | openpgp/src/types/revocation_key.rs | 2 | ||||
-rw-r--r-- | openpgp/src/types/server_preferences.rs | 2 | ||||
-rw-r--r-- | openpgp/src/types/timestamp.rs | 4 |
6 files changed, 19 insertions, 26 deletions
diff --git a/openpgp/src/types/features.rs b/openpgp/src/types/features.rs index 907f002e..caac3cd2 100644 --- a/openpgp/src/types/features.rs +++ b/openpgp/src/types/features.rs @@ -358,7 +358,7 @@ const FEATURE_FLAG_AEAD: usize = 1; #[cfg(test)] impl Arbitrary for Features { - fn arbitrary<G: Gen>(g: &mut G) -> Self { + fn arbitrary(g: &mut Gen) -> Self { Self::new(Vec::arbitrary(g)) } } diff --git a/openpgp/src/types/key_flags.rs b/openpgp/src/types/key_flags.rs index 50f96f6a..933df1ea 100644 --- a/openpgp/src/types/key_flags.rs +++ b/openpgp/src/types/key_flags.rs @@ -407,7 +407,7 @@ const KEY_FLAG_GROUP_KEY: usize = 7; #[cfg(test)] impl Arbitrary for KeyFlags { - fn arbitrary<G: Gen>(g: &mut G) -> Self { + fn arbitrary(g: &mut Gen) -> Self { Self::new(Vec::arbitrary(g)) } } diff --git a/openpgp/src/types/mod.rs b/openpgp/src/types/mod.rs index 9eac14d2..ba50cccd 100644 --- a/openpgp/src/types/mod.rs +++ b/openpgp/src/types/mod.rs @@ -263,27 +263,20 @@ impl fmt::Display for PublicKeyAlgorithm { #[cfg(test)] impl Arbitrary for PublicKeyAlgorithm { - fn arbitrary<G: Gen>(g: &mut G) -> Self { + fn arbitrary(g: &mut Gen) -> Self { u8::arbitrary(g).into() } } #[cfg(test)] impl PublicKeyAlgorithm { - pub(crate) fn arbitrary_for_signing<G: Gen>(g: &mut G) -> Self { - use rand::Rng; + pub(crate) fn arbitrary_for_signing(g: &mut Gen) -> Self { use self::PublicKeyAlgorithm::*; + #[allow(deprecated)] - let a = match g.gen_range(0, 5) { - 0 => RSAEncryptSign, - 1 => RSASign, - 2 => DSA, - 3 => ECDSA, - 4 => EdDSA, - _ => unreachable!(), - }; + let a = g.choose(&[RSAEncryptSign, RSASign, DSA, ECDSA, EdDSA]).unwrap(); assert!(a.for_signing()); - a + *a } } @@ -489,7 +482,7 @@ impl Curve { #[cfg(test)] impl Arbitrary for Curve { - fn arbitrary<G: Gen>(g: &mut G) -> Self { + fn arbitrary(g: &mut Gen) -> Self { match u8::arbitrary(g) % 8 { 0 => Curve::NistP256, 1 => Curve::NistP384, @@ -658,7 +651,7 @@ impl fmt::Display for SymmetricAlgorithm { #[cfg(test)] impl Arbitrary for SymmetricAlgorithm { - fn arbitrary<G: Gen>(g: &mut G) -> Self { + fn arbitrary(g: &mut Gen) -> Self { u8::arbitrary(g).into() } } @@ -767,7 +760,7 @@ impl fmt::Display for AEADAlgorithm { #[cfg(test)] impl Arbitrary for AEADAlgorithm { - fn arbitrary<G: Gen>(g: &mut G) -> Self { + fn arbitrary(g: &mut Gen) -> Self { u8::arbitrary(g).into() } } @@ -909,7 +902,7 @@ impl fmt::Display for CompressionAlgorithm { #[cfg(test)] impl Arbitrary for CompressionAlgorithm { - fn arbitrary<G: Gen>(g: &mut G) -> Self { + fn arbitrary(g: &mut Gen) -> Self { u8::arbitrary(g).into() } } @@ -1079,7 +1072,7 @@ impl HashAlgorithm { #[cfg(test)] impl Arbitrary for HashAlgorithm { - fn arbitrary<G: Gen>(g: &mut G) -> Self { + fn arbitrary(g: &mut Gen) -> Self { u8::arbitrary(g).into() } } @@ -1250,7 +1243,7 @@ impl fmt::Display for SignatureType { #[cfg(test)] impl Arbitrary for SignatureType { - fn arbitrary<G: Gen>(g: &mut G) -> Self { + fn arbitrary(g: &mut Gen) -> Self { u8::arbitrary(g).into() } } @@ -1394,7 +1387,7 @@ impl fmt::Display for ReasonForRevocation { #[cfg(test)] impl Arbitrary for ReasonForRevocation { - fn arbitrary<G: Gen>(g: &mut G) -> Self { + fn arbitrary(g: &mut Gen) -> Self { u8::arbitrary(g).into() } } @@ -1641,7 +1634,7 @@ impl fmt::Display for DataFormat { #[cfg(test)] impl Arbitrary for DataFormat { - fn arbitrary<G: Gen>(g: &mut G) -> Self { + fn arbitrary(g: &mut Gen) -> Self { u8::arbitrary(g).into() } } diff --git a/openpgp/src/types/revocation_key.rs b/openpgp/src/types/revocation_key.rs index b1e759cf..2e41224b 100644 --- a/openpgp/src/types/revocation_key.rs +++ b/openpgp/src/types/revocation_key.rs @@ -151,7 +151,7 @@ const REVOCATION_KEY_MASK_UNKNOWN: u8 = ! (REVOCATION_KEY_FLAG_MUST_BE_SET #[cfg(test)] impl Arbitrary for RevocationKey { - fn arbitrary<G: Gen>(g: &mut G) -> Self { + fn arbitrary(g: &mut Gen) -> Self { RevocationKey { pk_algo: Arbitrary::arbitrary(g), fp: Arbitrary::arbitrary(g), diff --git a/openpgp/src/types/server_preferences.rs b/openpgp/src/types/server_preferences.rs index 7adfb83a..347e66fe 100644 --- a/openpgp/src/types/server_preferences.rs +++ b/openpgp/src/types/server_preferences.rs @@ -276,7 +276,7 @@ const KEYSERVER_PREFERENCE_NO_MODIFY: usize = 7; #[cfg(test)] impl Arbitrary for KeyServerPreferences { - fn arbitrary<G: Gen>(g: &mut G) -> Self { + fn arbitrary(g: &mut Gen) -> Self { Self::new(Vec::arbitrary(g)) } } diff --git a/openpgp/src/types/timestamp.rs b/openpgp/src/types/timestamp.rs index 284b6ec9..d56171f3 100644 --- a/openpgp/src/types/timestamp.rs +++ b/openpgp/src/types/timestamp.rs @@ -252,7 +252,7 @@ impl Timestamp { #[cfg(test)] impl Arbitrary for Timestamp { - fn arbitrary<G: Gen>(g: &mut G) -> Self { + fn arbitrary(g: &mut Gen) -> Self { Timestamp(u32::arbitrary(g)) } } @@ -608,7 +608,7 @@ impl Timestamp { #[cfg(test)] impl Arbitrary for Duration { - fn arbitrary<G: Gen>(g: &mut G) -> Self { + fn arbitrary(g: &mut Gen) -> Self { Duration(u32::arbitrary(g)) } } |