pub fn quickcheck<A: Testable>(f: A)
Expand description
Convenience function for running QuickCheck.
This is an alias for QuickCheck::new().quickcheck(f)
.
Examples found in repository?
More examples
examples/sieve.rs (line 37)
28 29 30 31 32 33 34 35 36 37 38 39
fn main() {
fn prop_all_prime(n: usize) -> bool {
sieve(n).into_iter().all(is_prime)
}
fn prop_prime_iff_in_the_sieve(n: usize) -> bool {
sieve(n) == (0..(n + 1)).filter(|&i| is_prime(i)).collect::<Vec<_>>()
}
quickcheck(prop_all_prime as fn(usize) -> bool);
quickcheck(prop_prime_iff_in_the_sieve as fn(usize) -> bool);
}
examples/sort.rs (line 43)
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
fn main() {
fn is_sorted(xs: Vec<isize>) -> bool {
for win in xs.windows(2) {
if win[0] > win[1] {
return false;
}
}
true
}
fn keeps_length(xs: Vec<isize>) -> bool {
xs.len() == sort(&*xs).len()
}
quickcheck(keeps_length as fn(Vec<isize>) -> bool);
quickcheck(is_sorted as fn(Vec<isize>) -> bool)
}