Skip to content

Commit

Permalink
test rand a bit more
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Apr 22, 2019
1 parent b916a07 commit c3a8be6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions test-cargo-miri/tests/test.rs
Expand Up @@ -11,19 +11,25 @@ fn simple() {
fn fixed_rng() {
let mut rng = rand::rngs::StdRng::seed_from_u64(0xdeadcafe);
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);
}

#[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
Expand Down

0 comments on commit c3a8be6

Please sign in to comment.