diff options
author | pommicket <pommicket@gmail.com> | 2022-12-14 15:24:18 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-12-14 15:24:18 -0500 |
commit | 3f77c9f224c935aa56793bd548944e991cd4b0cd (patch) | |
tree | 0b28a7fa316a23f9e8254e74be96629e2e0be916 /gen_random_test | |
parent | e8bc993ed558e1b25a31e6a6fabac7853e1b1035 (diff) |
probabilities which don't add up to 1
Diffstat (limited to 'gen_random_test')
-rw-r--r-- | gen_random_test/src/lib.rs | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/gen_random_test/src/lib.rs b/gen_random_test/src/lib.rs index bea6190..0d2b1cc 100644 --- a/gen_random_test/src/lib.rs +++ b/gen_random_test/src/lib.rs @@ -1,39 +1,38 @@ - #[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}; + extern crate gen_random_proc_macro; + extern crate rand; + use gen_random::{gen_thread_random_vec, GenRandom}; use gen_random_proc_macro::GenRandom; - + #[derive(GenRandom, Debug)] enum Test1 { #[prob = 0.2] A(f32), #[prob = 0.8] - B(Option<f32>) + 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 }, + Variant2 { x: f32, y: f64, z: Test1 }, #[prob = 0.2] - Variant3(f32, Box<Test2>) + Variant3(f32, Box<Test2>), } - + #[derive(GenRandom, Debug)] enum LinkedList { - #[prob = 0.1] + #[prob = 10] Empty, - #[prob = 0.9] - Cons(f32, Box<LinkedList>) + #[prob = 90] + Cons(f32, Box<LinkedList>), } - + #[derive(GenRandom, Debug)] struct ScaleBias { #[bias = 1.0] @@ -49,19 +48,19 @@ mod tests { 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:?}"); } - + #[test] fn scale_bias() { let sb: Vec<ScaleBias> = gen_thread_random_vec(10); |