Macro test_macro::test_should_panic
source · [−]macro_rules! test_should_panic {
($func_name:ident, $func:expr) => { ... };
($func_name:ident, $message:literal, $func:expr) => { ... };
}Expand description
Test to see if it panics as expected.
The first argument should be the test case name, and the second argument should be the function or macro which is expected to panic internally.
Example
test_macro::test_should_panic!(test_case_name, panic!());fn panic() {
panic!();
}
test_macro::test_should_panic!(test_case_name, panic());Expected error message can be tested.
test_macro::test_should_panic!(test_case_name, "expected error message", panic("{}", String::from("expected error message")));