diff options
Diffstat (limited to 'gen_random_test/src/lib.rs')
-rw-r--r-- | gen_random_test/src/lib.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/gen_random_test/src/lib.rs b/gen_random_test/src/lib.rs index 00f5026..bea6190 100644 --- a/gen_random_test/src/lib.rs +++ b/gen_random_test/src/lib.rs @@ -33,6 +33,16 @@ mod tests { #[prob = 0.9] Cons(f32, Box<LinkedList>) } + + #[derive(GenRandom, Debug)] + struct ScaleBias { + #[bias = 1.0] + #[scale = 10.0] + a: f32, + #[bias = 2.0] + #[scale = 0.0] + b: f32, + } #[test] fn basic() { @@ -51,4 +61,18 @@ mod tests { let ll = LinkedList::gen_thread_random(); println!("{ll:?}"); } + + #[test] + fn scale_bias() { + let sb: Vec<ScaleBias> = gen_thread_random_vec(10); + println!("{sb:?}"); + for x in sb.iter() { + if x.a < 1.0 || x.a > 11.0 { + panic!("a field should be between 1 and 11; got {}", x.a); + } + if x.b != 2.0 { + panic!("b field should be exactly 2; got {}", x.b); + } + } + } } |