32 lines
855 B
Rust
Raw Normal View History

2019-06-12 18:30:05 +02:00
use rand::{SeedableRng, Rng, rngs::SmallRng};
2019-02-07 13:00:42 +01:00
2019-05-15 14:45:15 +02: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).
#[test]
2019-02-07 13:00:42 +01:00
fn simple() {
assert_eq!(4, 4);
}
#[test]
2019-04-16 20:12:55 +02:00
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>();
2019-06-12 18:19:50 +02:00
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>();
2019-06-12 18:19:50 +02:00
let _val = rng.gen::<isize>();
let _val = rng.gen::<i128>();
}
2018-12-19 11:11:01 +01:00
// A test that won't work on miri
2019-02-07 13:00:42 +01:00
#[cfg(not(miri))]
2018-12-19 11:11:01 +01:00
#[test]
fn does_not_work_on_miri() {
let x = 0u8;
assert!(&x as *const _ as usize % 4 < 4);
}