Skip to content

Commit 8f670e6

Browse files
committed
test rand a bit more
1 parent deb0ff4 commit 8f670e6

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

test-cargo-miri/src/main.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ mod test {
1919
fn rng() {
2020
let mut rng = rand::rngs::StdRng::seed_from_u64(0xcafebeef);
2121
let x: u32 = rng.gen();
22-
let y: u32 = rng.gen();
23-
assert_ne!(x, y);
22+
let y: usize = rng.gen();
23+
let z: u128 = rng.gen();
24+
assert_ne!(x as usize, y);
25+
assert_ne!(y as u128, z);
2426
}
2527
}

test-cargo-miri/tests/test.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@ fn simple() {
77
assert_eq!(4, 4);
88
}
99

10-
// Having more than 1 test does seem to make a difference
11-
// (i.e., this calls ptr::swap which having just one test does not).
1210
#[test]
1311
fn entropy_rng() {
1412
// Use this opportunity to test querying the RNG (needs an external crate, hence tested here and not in the compiletest suite)
1513
let mut rng = SmallRng::from_entropy();
1614
let _val = rng.gen::<i32>();
15+
let _val = rng.gen::<isize>();
16+
let _val = rng.gen::<i128>();
1717

1818
// Also try per-thread RNG.
1919
let mut rng = rand::thread_rng();
2020
let _val = rng.gen::<i32>();
21+
let _val = rng.gen::<isize>();
22+
let _val = rng.gen::<i128>();
2123
}
2224

2325
// A test that won't work on miri

0 commit comments

Comments
 (0)