1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//! 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._
//!
//! For the same purpose, `shoud_panic` attribute is provided in the
//! Rust standard, but it is not so useful, hence we created this crate.
//!
//! # Examples
//!
//! Example with always panic.
//!
//! ```no_run
//! use test_panic::prelude::*;
//!
//! #[test]
//! fn test() {
//! let result = test_panic(|| panic!("message."));
//! assert!(result.is_panic());
//! assert!(result.message().contains("message"));
//! }
//! ```
//!
//! Example with multiple tests.
//!
//! ```no_run
//! use test_panic::prelude::*;
//!
//! #[test]
//! fn with_multi_tests() {
//! let datas = [
//! ((10, 3), ok(3)),
//! ((10, 0), ng()),
//! ((10, 15), msg("Result is too small")),
//! ];
//!
//! for ((x, y), tobe) in datas {
//! let asis = test_panic(|| divide(x, y));
//! assert_eqa!(asis, tobe);
//! }
//! }
//!
//! fn divide(x: i32, y: i32) -> i32 {
//! assert!(y > 0);
//! assert!(x / y >= 1, "Result is too small");
//! x / y
//! }
//! ```
pub use *;
pub use *;