Skip to content

Commit 828f1ff

Browse files
committed
Re-add rng test
1 parent 8f41199 commit 828f1ff

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test-cargo-miri/tests/test.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use rand::{rngs::SmallRng, Rng, SeedableRng};
2+
13
// Having more than 1 test does seem to make a difference
24
// (i.e., this calls ptr::swap which having just one test does not).
35
#[test]
@@ -18,6 +20,22 @@ fn does_not_work_on_miri() {
1820
assert!(&x as *const _ as usize % 4 < 4);
1921
}
2022

23+
// Make sure integration tests can access dev-dependencies
24+
#[test]
25+
fn entropy_rng() {
26+
// Try seeding with "real" entropy.
27+
let mut rng = SmallRng::from_entropy();
28+
let _val = rng.gen::<i32>();
29+
let _val = rng.gen::<isize>();
30+
let _val = rng.gen::<i128>();
31+
32+
// Also try per-thread RNG.
33+
let mut rng = rand::thread_rng();
34+
let _val = rng.gen::<i32>();
35+
let _val = rng.gen::<isize>();
36+
let _val = rng.gen::<i128>();
37+
}
38+
2139
#[test]
2240
fn cargo_env() {
2341
assert_eq!(env!("CARGO_PKG_NAME"), "cargo-miri-test");

0 commit comments

Comments
 (0)