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)
28fn main() {
29 fn prop_all_prime(n: usize) -> bool {
30 sieve(n).into_iter().all(is_prime)
31 }
32
33 fn prop_prime_iff_in_the_sieve(n: usize) -> bool {
34 sieve(n) == (0..(n + 1)).filter(|&i| is_prime(i)).collect::<Vec<_>>()
35 }
36
37 quickcheck(prop_all_prime as fn(usize) -> bool);
38 quickcheck(prop_prime_iff_in_the_sieve as fn(usize) -> bool);
39}
examples/sort.rs (line 43)
30fn main() {
31 fn is_sorted(xs: Vec<isize>) -> bool {
32 for win in xs.windows(2) {
33 if win[0] > win[1] {
34 return false;
35 }
36 }
37 true
38 }
39
40 fn keeps_length(xs: Vec<isize>) -> bool {
41 xs.len() == sort(&*xs).len()
42 }
43 quickcheck(keeps_length as fn(Vec<isize>) -> bool);
44
45 quickcheck(is_sorted as fn(Vec<isize>) -> bool)
46}