Crates.io | test_panic |
lib.rs | test_panic |
version | 0.3.1 |
source | src |
created_at | 2023-06-30 05:42:23.373536 |
updated_at | 2024-01-14 22:21:10.662163 |
description | Utility for test cases with panic. |
homepage | |
repository | https://github.com/nossie531/test_panic |
max_upload_size | |
id | 904130 |
size | 22,470 |
Utility for test cases with panic.
The author of this crate is not good at English.
Forgive me if the document is hard to read.
Provides functions for test with panic. For the same purpose, the shoud_panic
attribute is provided in the Rust standard, but it is not so useful, hence we
created this crate.
Example with this crate.
#[test]
fn test() {
let result = test_panic(|| panic!("message."));
assert!(result.is_panic());
assert!(result.message().contains("message."));
}
Example with should_panic
.
#[test]
#[should_panic(expected = "message.")]
fn test() {
// Suppresses standard error output.
panic::set_hook(Box::new(|_| {}));
panic!("message.");
}
v0.3.1
v0.3.0
must_use
annotations are added at TestPanicResult
.v0.2.0
TestPanicResult
holds value on cases where no panic occurred.