50 lines
1.2 KiB
Rust
Raw Normal View History

#[test]
fn simple() {
assert_eq!(4, 4);
}
// A test that won't work on miri (tests disabling tests).
2019-06-29 13:33:47 +02:00
#[test]
#[cfg_attr(miri, ignore)]
2019-06-29 13:33:47 +02:00
fn does_not_work_on_miri() {
2022-07-21 10:48:41 -04:00
// Only do this where inline assembly is stable.
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
unsafe {
std::arch::asm!("foo");
}
2019-06-29 13:33:47 +02:00
}
// Make sure integration tests can access both dependencies and dev-dependencies
#[test]
fn deps() {
{
use byteorder::{BigEndian, ByteOrder};
let _n = <BigEndian as ByteOrder>::read_u64(&[1, 2, 3, 4, 5, 6, 7, 8]);
}
{
use byteorder_2::{BigEndian, ByteOrder};
let _n = <BigEndian as ByteOrder>::read_u64(&[1, 2, 3, 4, 5, 6, 7, 8]);
}
}
#[test]
fn cargo_env() {
assert_eq!(env!("CARGO_PKG_NAME"), "cargo-miri-test");
env!("CARGO_BIN_EXE_cargo-miri-test"); // Asserts that this exists.
}
2019-11-17 11:09:16 -05:00
#[test]
2022-05-21 16:10:08 +02:00
#[should_panic(expected = "Explicit panic")]
2022-05-22 00:59:49 +02:00
fn do_panic() // In large, friendly letters :)
{
2019-11-17 11:09:16 -05:00
panic!("Explicit panic from test!");
}
// A different way of raising a panic
#[test]
2020-02-21 11:03:52 +01:00
#[allow(unconditional_panic)]
2022-05-21 16:10:08 +02:00
#[should_panic(expected = "the len is 0 but the index is 42")]
fn fail_index_check() {
[][42]
}