#[cfg(test)]
impl Arbitrary for PrintableDep {
fn arbitrary(g: &mut Gen) -> Self {
let hash = Hash::Blake3(std::array::from_fn(|_| Arbitrary::arbitrary(g))).to_base32();
Self {
type_: Arbitrary::arbitrary(g),
hash,
}
}
fn shrink(&self) -> Box<dyn Iterator<Item = Self>> {
Box::new(
(self.type_.clone(), self.hash.clone())
.shrink()
.map(|(type_, hash)| Self { type_, hash }),
)
}
}
#[cfg(test)]
impl Arbitrary for DepType {
fn arbitrary(g: &mut Gen) -> Self {
let options = [
Self::ExtraKnown,
Self::ExtraUnknown,
Self::Numbered(Arbitrary::arbitrary(g), Arbitrary::arbitrary(g)),
];
g.choose(&options).unwrap().clone()
}
fn shrink(&self) -> Box<dyn Iterator<Item = Self>> {
match self {
DepType::ExtraKnown | DepType::ExtraUnknown => Box::new(std::iter::empty()),
DepType::Numbered(n, p) => {
Box::new((*n, *p).shrink().map(|(n, p)| Self::Numbered(n, p)))
}
}
}
}