use super::{Generator, TestCase};
pub fn unit() -> JustGenerator<()> {
just(())
}
pub struct JustGenerator<T> {
value: T,
}
impl<T: Clone + Send + Sync> Generator<T> for JustGenerator<T> {
fn do_draw(&self, _tc: &TestCase) -> T {
self.value.clone()
}
}
pub fn just<T: Clone + Send + Sync>(value: T) -> JustGenerator<T> {
JustGenerator { value }
}
pub struct BoolGenerator;
impl Generator<bool> for BoolGenerator {
fn do_draw(&self, tc: &TestCase) -> bool {
tc.generate_boolean(0.5)
}
}
pub fn booleans() -> BoolGenerator {
BoolGenerator
}