Debian Codegraph @

debian/missing-sources/proptest/examples/tutorial-strategy-play.rs

raw
1 //-
2 // Copyright 2017 Jason Lingle
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10 // Shows how to pick values from a strategy.
11 //
12 // This is *not* how proptest is normally used; it is simply used to play
13 // around with value generation.
14
15 use proptest::strategy::{Strategy, ValueTree};
16 use proptest::test_runner::TestRunner;
17
18 fn main() {
19 let mut runner = TestRunner::default();
20 let int_val = (0..100i32).new_tree(&mut runner).unwrap();
21 let str_val = "[a-z]{1,4}\\p{Cyrillic}{1,4}\\p{Greek}{1,4}"
22 .new_tree(&mut runner)
23 .unwrap();
24 println!(
25 "int_val = {}, str_val = {}",
26 int_val.current(),
27 str_val.current()
28 );
29 }