rust/test-cargo-miri/tests/test.rs

27 lines
544 B
Rust
Raw Normal View History

2019-02-07 06:00:42 -06:00
extern crate rand;
use rand::{Rng, SeedableRng};
#[test]
2019-02-07 06:00:42 -06:00
fn simple() {
assert_eq!(4, 4);
}
// 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 06:00:42 -06:00
fn 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);
}
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);
}