quickcheck 0.1.7

Automatic property based testing with shrinking.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
extern crate quickcheck;

use quickcheck::{TestResult, quickcheck};

fn main() {
    fn prop(length: uint, index: uint) -> TestResult {
        let v = Vec::from_fn(length, |i| i);

        if index < length {
            TestResult::discard()
        } else {
            TestResult::must_fail(move || {
                v[index]
            })
        }
    }
    quickcheck(prop);
}