blob: 00f50263496a8a23fc0b9aa3efecfcae7da030b6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#[cfg(test)]
mod tests {
extern crate rand;
extern crate gen_random_proc_macro;
extern crate gen_random;
use gen_random::{GenRandom, gen_thread_random_vec};
use gen_random_proc_macro::GenRandom;
#[derive(GenRandom, Debug)]
enum Test1 {
#[prob = 0.2]
A(f32),
#[prob = 0.8]
B(Option<f32>)
}
#[derive(GenRandom, Debug)]
#[allow(dead_code)]
enum Test2 {
#[prob = 0.1]
Variant1,
#[prob = 0.7]
Variant2 { x : f32, y: f64, z: Test1 },
#[prob = 0.2]
Variant3(f32, Box<Test2>)
}
#[derive(GenRandom, Debug)]
enum LinkedList {
#[prob = 0.1]
Empty,
#[prob = 0.9]
Cons(f32, Box<LinkedList>)
}
#[test]
fn basic() {
let tests1: Vec<Test1> = gen_thread_random_vec(10);
println!("{tests1:?}");
}
#[test]
fn many_types_of_variants() {
let tests2: Vec<Test2> = gen_thread_random_vec(10);
println!("{tests2:?}");
}
#[test]
fn linked_list() {
let ll = LinkedList::gen_thread_random();
println!("{ll:?}");
}
}
|