use super::summary::{OutputFileName, ZipStoreOutput};
use proptest::prelude::*;
pub fn arb_output_file_name() -> impl Strategy<Value = OutputFileName> {
let suffixes = prop_oneof![Just("-stdout"), Just("-stderr"), Just("-combined")];
("[0-9a-f]{16}", suffixes).prop_map(|(hash, suffix)| {
let json = format!(r#""{hash}{suffix}""#);
serde_json::from_str(&json).expect("valid output file name")
})
}
impl Arbitrary for OutputFileName {
type Parameters = ();
type Strategy = BoxedStrategy<Self>;
fn arbitrary_with(_: Self::Parameters) -> Self::Strategy {
arb_output_file_name().boxed()
}
}
impl Arbitrary for ZipStoreOutput {
type Parameters = ();
type Strategy = BoxedStrategy<Self>;
fn arbitrary_with(_: Self::Parameters) -> Self::Strategy {
prop_oneof![
Just(ZipStoreOutput::Empty),
any::<OutputFileName>().prop_map(|file_name| ZipStoreOutput::Full { file_name }),
(any::<OutputFileName>(), any::<u64>()).prop_map(|(file_name, original_size)| {
ZipStoreOutput::Truncated {
file_name,
original_size,
}
}),
]
.boxed()
}
}