Derive macro for quickcheck::Arbitrary.
Expands to calling Arbitrary::arbitrary
on every field of a struct.
use derive_quickcheck_arbitrary::Arbitrary;
#[derive(Clone, Arbitrary)]
struct Yakshaver {
id: usize,
name: String,
}
You can customise field generation by providing a callable that accepts &mut quickcheck::Gen.
#[derive(Clone, Arbitrary)]
struct Yakshaver {
#[arbitrary(gen(|g| num::clamp(usize::arbitrary(g), 0, 10_000) ))]
id: usize,
name: String,
}
You can skip enum variants:
#[derive(Clone, Arbitrary)]
enum YakType {
Domestic {
name: String,
},
Wild,
#[arbitrary(skip)]
Alien,
}