Function quickcheck

Source
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?
examples/btree_set_range.rs (line 54)
53fn main() {
54    quickcheck(check_range as fn(_, _) -> TestResult);
55}
More examples
Hide additional examples
examples/reverse.rs (line 15)
11fn main() {
12    fn equality_after_applying_twice(xs: Vec<isize>) -> bool {
13        xs == reverse(&reverse(&xs))
14    }
15    quickcheck(equality_after_applying_twice as fn(Vec<isize>) -> bool);
16}
examples/reverse_single.rs (line 18)
11fn main() {
12    fn prop(xs: Vec<isize>) -> TestResult {
13        if xs.len() != 1 {
14            return TestResult::discard();
15        }
16        TestResult::from_bool(xs == reverse(&*xs))
17    }
18    quickcheck(prop as fn(Vec<isize>) -> TestResult);
19}
examples/out_of_bounds.rs (line 12)
3fn main() {
4    fn prop(length: usize, index: usize) -> TestResult {
5        let v: Vec<_> = (0..length).collect();
6        if index < length {
7            TestResult::discard()
8        } else {
9            TestResult::must_fail(move || v[index])
10        }
11    }
12    quickcheck(prop as fn(usize, usize) -> TestResult);
13}
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}