diff options
author | Nora Widdecke <nora@sequoia-pgp.org> | 2020-05-12 17:07:44 +0200 |
---|---|---|
committer | Nora Widdecke <nora@sequoia-pgp.org> | 2020-06-08 14:36:13 +0200 |
commit | c51d96b98f1ed92fe7bc6d964abb0d2a8616bae1 (patch) | |
tree | 9fb9ea374e712da619c0985b9ddc0f4377b0b749 /openpgp/src/crypto/mpi.rs | |
parent | 5be97d9c6ee82f068a5b38aa455f31497d3f20bf (diff) |
openpgp: Introduce feature flag for quickcheck.
- Make quickcheck dependency optional.
- Make quickcheck a dev-dependency for tests.
- Fix doctests for
- cert::ValidCert::user_attributes,
- cert::builder::CertBuilder::add_user_attribute,
- cert::revoke::UserAttributeRevocationBuilder
- cert::revoke::UserAttributeRevocationBuilder::build.
Doctests do not use cfg(test), so we cannot use quickcheck in there.
Diffstat (limited to 'openpgp/src/crypto/mpi.rs')
-rw-r--r-- | openpgp/src/crypto/mpi.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/openpgp/src/crypto/mpi.rs b/openpgp/src/crypto/mpi.rs index 13bc0007..1dd2cd30 100644 --- a/openpgp/src/crypto/mpi.rs +++ b/openpgp/src/crypto/mpi.rs @@ -3,7 +3,9 @@ use std::fmt; use std::cmp::Ordering; +#[cfg(any(test, feature = "quickcheck"))] use quickcheck::{Arbitrary, Gen}; +#[cfg(any(test, feature = "quickcheck"))] use rand::Rng; use crate::types::{ @@ -184,6 +186,7 @@ impl Hash for MPI { } } +#[cfg(any(test, feature = "quickcheck"))] impl Arbitrary for MPI { fn arbitrary<G: Gen>(g: &mut G) -> Self { loop { @@ -409,6 +412,7 @@ impl Hash for PublicKey { } } +#[cfg(any(test, feature = "quickcheck"))] impl Arbitrary for PublicKey { fn arbitrary<G: Gen>(g: &mut G) -> Self { use self::PublicKey::*; @@ -678,6 +682,7 @@ impl Hash for SecretKeyMaterial { } } +#[cfg(any(test, feature = "quickcheck"))] impl Arbitrary for SecretKeyMaterial { fn arbitrary<G: Gen>(g: &mut G) -> Self { match g.gen_range(0, 6) { @@ -780,6 +785,7 @@ impl Hash for Ciphertext { } } +#[cfg(any(test, feature = "quickcheck"))] impl Arbitrary for Ciphertext { fn arbitrary<G: Gen>(g: &mut G) -> Self { match g.gen_range(0, 3) { @@ -865,6 +871,7 @@ impl Hash for Signature { } } +#[cfg(any(test, feature = "quickcheck"))] impl Arbitrary for Signature { fn arbitrary<G: Gen>(g: &mut G) -> Self { match g.gen_range(0, 4) { |