]> git.lizzy.rs Git - rust.git/blob - test-cargo-miri/tests/test.rs
fix tests
[rust.git] / test-cargo-miri / tests / test.rs
1 use rand::{FromEntropy, Rng, rngs::SmallRng};
2
3 // Having more than 1 test does seem to make a difference
4 // (i.e., this calls ptr::swap which having just one test does not).
5 #[test]
6 fn simple() {
7     assert_eq!(4, 4);
8 }
9
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).
12 #[test]
13 fn entropy_rng() {
14     // Use this opportunity to test querying the RNG (needs an external crate, hence tested here and not in the compiletest suite)
15     let mut rng = SmallRng::from_entropy();
16     let _val = rng.gen::<i32>();
17
18     // Also try per-thread RNG.
19     let mut rng = rand::thread_rng();
20     let _val = rng.gen::<i32>();
21 }
22
23 // A test that won't work on miri
24 #[cfg(not(miri))]
25 #[test]
26 fn does_not_work_on_miri() {
27     let x = 0u8;
28     assert!(&x as *const _ as usize % 4 < 4);
29 }