summaryrefslogtreecommitdiff
path: root/gen_random_test
diff options
context:
space:
mode:
Diffstat (limited to 'gen_random_test')
-rw-r--r--gen_random_test/src/lib.rs33
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);