diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-03-31 17:17:11 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-04-01 16:15:00 +0200 |
commit | 6ffef8ff27bbf75e1a5f237cf0ae99556fbbdc9f (patch) | |
tree | 780bc281b5191b375deb2ba7dabbca976793654b | |
parent | 45b43bb2f5e8dd984e0b8a952dd9f6f6835d5317 (diff) |
openpgp: Implement Arbitrary for Packet.
-rw-r--r-- | openpgp/src/packet/mod.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/openpgp/src/packet/mod.rs b/openpgp/src/packet/mod.rs index af911578..17222bce 100644 --- a/openpgp/src/packet/mod.rs +++ b/openpgp/src/packet/mod.rs @@ -230,6 +230,23 @@ impl<'a> DerefMut for Packet { } } } + +impl Arbitrary for Packet { + fn arbitrary<G: Gen>(g: &mut G) -> Self { + use rand::Rng; + match g.gen_range(0, 8) { + 0 => OnePassSig::arbitrary(g).into(), + 1 => Marker::arbitrary(g).into(), + 2 => Trust::arbitrary(g).into(), + 3 => UserID::arbitrary(g).into(), + 4 => UserAttribute::arbitrary(g).into(), + 5 => Literal::arbitrary(g).into(), + 6 => PKESK::arbitrary(g).into(), + 7 => SKESK::arbitrary(g).into(), + _ => unreachable!(), + } + } +} /// Fields used by multiple packet types. #[derive(Debug, Clone)] |