use super::{arb_dots, have};
use crate::metis::DotSet;
use proptest::prelude::*;
proptest! {
#[test]
fn prop_have_set_bytes_round_trip(dots in arb_dots()) {
let set = have(&dots);
prop_assert_eq!(set.encoded_len(), set.to_bytes().len());
prop_assert_eq!(set.exceptions().count(), set.exceptions_len());
prop_assert_eq!(DotSet::from_bytes(&set.to_bytes()), Ok(set));
}
#[test]
fn prop_have_set_bytes_are_canonical(
(dots, permuted) in arb_dots()
.prop_flat_map(|d| (Just(d.clone()), Just(d).prop_shuffle())),
) {
let set = have(&dots);
let other = have(&permuted);
prop_assert_eq!(&set, &other);
let bytes = set.to_bytes();
prop_assert_eq!(&bytes, &other.to_bytes());
let (decoded, tail) = DotSet::from_prefix(&bytes).expect("own frame decodes");
prop_assert!(tail.is_empty());
prop_assert_eq!(decoded.to_bytes(), bytes);
}
}