2017-01-24 10:55:42 -06:00
|
|
|
#[test]
|
2022-07-21 07:06:11 -05:00
|
|
|
fn simple() {
|
2017-01-24 10:55:42 -06:00
|
|
|
assert_eq!(4, 4);
|
|
|
|
}
|
2018-11-27 08:06:51 -06:00
|
|
|
|
2019-11-30 03:31:53 -06:00
|
|
|
// A test that won't work on miri (tests disabling tests).
|
2019-06-29 06:33:47 -05:00
|
|
|
#[test]
|
2019-12-07 04:55:19 -06:00
|
|
|
#[cfg_attr(miri, ignore)]
|
2019-06-29 06:33:47 -05:00
|
|
|
fn does_not_work_on_miri() {
|
2022-07-21 09:48:41 -05: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 06:33:47 -05:00
|
|
|
}
|
|
|
|
|
2022-07-21 07:06:11 -05:00
|
|
|
// Make sure integration tests can access both dependencies and dev-dependencies
|
2019-04-16 12:12:56 -05:00
|
|
|
#[test]
|
2022-07-21 07:06:11 -05:00
|
|
|
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]);
|
|
|
|
}
|
2019-04-16 12:12:56 -05:00
|
|
|
}
|
|
|
|
|
2020-09-09 01:51:41 -05:00
|
|
|
#[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 10:09:16 -06:00
|
|
|
#[test]
|
2022-05-21 09:10:08 -05:00
|
|
|
#[should_panic(expected = "Explicit panic")]
|
2022-05-21 17:59:49 -05:00
|
|
|
fn do_panic() // In large, friendly letters :)
|
|
|
|
{
|
2019-11-17 10:09:16 -06:00
|
|
|
panic!("Explicit panic from test!");
|
|
|
|
}
|
2019-11-30 03:37:14 -06:00
|
|
|
|
2022-07-21 07:06:11 -05:00
|
|
|
// A different way of raising a panic
|
2019-11-30 03:37:14 -06:00
|
|
|
#[test]
|
2020-02-21 04:03:52 -06:00
|
|
|
#[allow(unconditional_panic)]
|
2022-05-21 09:10:08 -05:00
|
|
|
#[should_panic(expected = "the len is 0 but the index is 42")]
|
2019-11-30 03:37:14 -06:00
|
|
|
fn fail_index_check() {
|
|
|
|
[][42]
|
|
|
|
}
|