File: out_of_bounds.rs

package info (click to toggle)
rust-quickcheck 1.0.3-6
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 336 kB
  • sloc: makefile: 4
file content (13 lines) | stat: -rw-r--r-- 364 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
use quickcheck::{quickcheck, TestResult};

fn main() {
    fn prop(length: usize, index: usize) -> TestResult {
        let v: Vec<_> = (0..length).collect();
        if index < length {
            TestResult::discard()
        } else {
            TestResult::must_fail(move || v[index])
        }
    }
    quickcheck(prop as fn(usize, usize) -> TestResult);
}