2019-05-17 08:03:28 -05:00
|
|
|
use rand::{FromEntropy, Rng, rngs::SmallRng};
|
2019-02-07 06:00:42 -06:00
|
|
|
|
2019-05-15 07:45:15 -05:00
|
|
|
// Having more than 1 test does seem to make a difference
|
|
|
|
// (i.e., this calls ptr::swap which having just one test does not).
|
2017-01-24 10:55:42 -06:00
|
|
|
#[test]
|
2019-02-07 06:00:42 -06:00
|
|
|
fn simple() {
|
2017-01-24 10:55:42 -06:00
|
|
|
assert_eq!(4, 4);
|
|
|
|
}
|
2018-11-27 08:06:51 -06:00
|
|
|
|
|
|
|
// Having more than 1 test does seem to make a difference
|
|
|
|
// (i.e., this calls ptr::swap which having just one test does not).
|
2019-04-16 12:12:56 -05:00
|
|
|
#[test]
|
2019-04-16 13:12:55 -05:00
|
|
|
fn entropy_rng() {
|
2019-04-21 14:37:06 -05:00
|
|
|
// 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>();
|
2019-04-16 12:49:36 -05:00
|
|
|
|
2019-04-21 14:37:06 -05:00
|
|
|
// Also try per-thread RNG.
|
|
|
|
let mut rng = rand::thread_rng();
|
|
|
|
let _val = rng.gen::<i32>();
|
2019-04-16 12:12:56 -05:00
|
|
|
}
|
|
|
|
|
2018-12-19 04:11:01 -06:00
|
|
|
// A test that won't work on miri
|
2019-02-07 06:00:42 -06:00
|
|
|
#[cfg(not(miri))]
|
2018-12-19 04:11:01 -06:00
|
|
|
#[test]
|
|
|
|
fn does_not_work_on_miri() {
|
|
|
|
let x = 0u8;
|
|
|
|
assert!(&x as *const _ as usize % 4 < 4);
|
|
|
|
}
|