Skip to content

Commit 99ffcc9

Browse files
authored
test: add tests of Uniform::<Position>::new_inclusive (#256)
1 parent 2a9c195 commit 99ffcc9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

forrustts-core/tests/tests.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,20 @@ mod test_rand_traits {
1919
}
2020
}
2121
}
22+
23+
proptest! {
24+
#[test]
25+
fn test_uniform_position_inclusive(a in 0..i64::MAX, b in 0..i64::MAX,
26+
seed in 0..u64::MAX) {
27+
if a != b { // else rand will panic
28+
let lo = Position::new_valid(std::cmp::min(a, b));
29+
let hi = Position::new_valid(std::cmp::max(a, b));
30+
let upos = rand::distributions::Uniform::<Position>::new_inclusive(lo, hi);
31+
let mut rng = rand::rngs::StdRng::seed_from_u64(seed);
32+
for _ in 0..100 {
33+
let _ = rng.sample(upos);
34+
}
35+
}
36+
}
37+
}
2238
}

0 commit comments

Comments
 (0)