use proptest::{arbitrary::StrategyFor, prelude::*, strategy::MapInto};
use crate::{Utf8Path, Utf8PathBuf};
#[cfg(feature = "proptest1")]
impl Arbitrary for Utf8PathBuf {
type Parameters = <String as Arbitrary>::Parameters;
type Strategy = BoxedStrategy<Self>;
fn arbitrary_with(args: Self::Parameters) -> Self::Strategy {
(
any::<bool>(),
prop::collection::vec(any_with::<String>(args), 0..8),
)
.prop_map(|(is_relative, components)| {
let initial_component =
is_relative.then(|| format!("{}", std::path::MAIN_SEPARATOR));
initial_component
.into_iter()
.chain(components.into_iter())
.collect()
})
.boxed()
}
}
#[cfg(feature = "proptest1")]
impl Arbitrary for Box<Utf8Path> {
type Parameters = <Utf8PathBuf as Arbitrary>::Parameters;
type Strategy = MapInto<StrategyFor<Utf8PathBuf>, Self>;
fn arbitrary_with(args: Self::Parameters) -> Self::Strategy {
any_with::<Utf8PathBuf>(args).prop_map_into()
}
}