test rand a bit more
This commit is contained in:
parent
deb0ff46eb
commit
8f670e6b8b
2 changed files with 8 additions and 4 deletions
|
|
@ -19,7 +19,9 @@ mod test {
|
|||
fn rng() {
|
||||
let mut rng = rand::rngs::StdRng::seed_from_u64(0xcafebeef);
|
||||
let x: u32 = rng.gen();
|
||||
let y: u32 = rng.gen();
|
||||
assert_ne!(x, y);
|
||||
let y: usize = rng.gen();
|
||||
let z: u128 = rng.gen();
|
||||
assert_ne!(x as usize, y);
|
||||
assert_ne!(y as u128, z);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,17 +7,19 @@ fn simple() {
|
|||
assert_eq!(4, 4);
|
||||
}
|
||||
|
||||
// Having more than 1 test does seem to make a difference
|
||||
// (i.e., this calls ptr::swap which having just one test does not).
|
||||
#[test]
|
||||
fn entropy_rng() {
|
||||
// Use this opportunity to test querying the RNG (needs an external crate, hence tested here and not in the compiletest suite)
|
||||
let mut rng = SmallRng::from_entropy();
|
||||
let _val = rng.gen::<i32>();
|
||||
let _val = rng.gen::<isize>();
|
||||
let _val = rng.gen::<i128>();
|
||||
|
||||
// Also try per-thread RNG.
|
||||
let mut rng = rand::thread_rng();
|
||||
let _val = rng.gen::<i32>();
|
||||
let _val = rng.gen::<isize>();
|
||||
let _val = rng.gen::<i128>();
|
||||
}
|
||||
|
||||
// A test that won't work on miri
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue