rust/test-cargo-miri/src/main.rs

28 lines
654 B
Rust
Raw Normal View History

2017-06-29 12:59:47 -05:00
use byteorder::{BigEndian, ByteOrder};
fn main() {
2017-06-29 12:59:47 -05:00
let buf = &[1,2,3,4];
let n = <BigEndian as ByteOrder>::read_u32(buf);
assert_eq!(n, 0x01020304);
println!("{:#010x}", n);
for arg in std::env::args() {
eprintln!("{}", arg);
}
}
2019-02-07 06:00:42 -06:00
#[cfg(test)]
mod test {
use rand::{Rng, SeedableRng};
// Make sure in-crate tests with dev-dependencies work
#[test]
fn rng() {
let mut rng = rand::rngs::StdRng::seed_from_u64(0xcafebeef);
let x: u32 = rng.gen();
2019-06-12 11:19:50 -05:00
let y: usize = rng.gen();
let z: u128 = rng.gen();
assert_ne!(x as usize, y);
assert_ne!(y as u128, z);
2019-02-07 06:00:42 -06:00
}
}