rust/test-cargo-miri/src/main.rs
2019-06-29 14:34:08 +02:00

31 lines
760 B
Rust

use byteorder::{BigEndian, ByteOrder};
fn main() {
// Exercise external crate, printing to stdout.
let buf = &[1,2,3,4];
let n = <BigEndian as ByteOrder>::read_u32(buf);
assert_eq!(n, 0x01020304);
println!("{:#010x}", n);
// Access program arguments, printing to stderr.
for arg in std::env::args() {
eprintln!("{}", arg);
}
}
#[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();
let y: usize = rng.gen();
let z: u128 = rng.gen();
assert_ne!(x as usize, y);
assert_ne!(y as u128, z);
}
}