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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//! # Overview
//! `test_case` crate provides procedural macro attribute that generates parametrized test instances.
//!
//! # Getting Started
//!
//! Crate has to be added as a dependency to `Cargo.toml`:
//!
//! ```toml
//! [dev-dependencies]
//! test-case = "*"
//! ```
//!
//! and imported to the scope of a block where it's being called
//! (since attribute name collides with rust's built-in `custom_test_frameworks`) via:
//!
//! ```rust
//! use test_case::test_case;
//! ```
//!
//! # Example usage:
//!
//! ```rust
//! #[cfg(test)]
//! mod tests {
//!     use test_case::test_case;
//!
//!     #[test_case(-2, -4 ; "when both operands are negative")]
//!     #[test_case(2,  4  ; "when both operands are positive")]
//!     #[test_case(4,  2  ; "when operands are swapped")]
//!     fn multiplication_tests(x: i8, y: i8) {
//!         let actual = (x * y).abs();
//!
//!         assert_eq!(8, actual)
//!     }
//! }
//! ```
//!
//! Output from `cargo test` for this example:
//!
//! ```sh
//! $ cargo test
//!
//! running 4 tests
//! test tests::multiplication_tests::when_both_operands_are_negative ... ok
//! test tests::multiplication_tests::when_both_operands_are_positive ... ok
//! test tests::multiplication_tests::when_operands_are_swapped ... ok
//!
//! test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
//! ```
//!
//! ## Test Matrix
//!
//! The `#[test_matrix(...)]` macro allows generating multiple test cases from the
//! Cartesian product of one or more possible values for each test function argument. The
//! number of arguments to the `test_matrix` macro must be the same as the number of arguments to
//! the test function. Each macro argument can be:
//!
//!     1. A list in array (`[x, y, ...]`) or tuple (`(x, y, ...)`) syntax. The values can be any
//!        valid [expression](https://doc.rust-lang.org/reference/expressions.html).
//!     2. A closed numeric range expression (e.g. `0..100` or `1..=99`), which will generate
//!        argument values for all integers in the range.
//!     3. A single expression, which can be used to keep one argument constant while varying the
//!        other test function arguments using a list or range.
//!
//! ### Example usage:
//!
//! ```rust
//! #[cfg(test)]
//! mod tests {
//!     use test_case::test_matrix;
//!
//!     #[test_matrix(
//!         [-2, 2],
//!         [-4, 4]
//!     )]
//!     fn multiplication_tests(x: i8, y: i8) {
//!         let actual = (x * y).abs();
//!
//!         assert_eq!(8, actual)
//!     }
//! }
//! ```
//!
//! # MSRV Policy
//!
//! Starting with version 3.0 and up `test-case` introduces policy of only supporting latest stable Rust.
//! These changes may happen overnight, so if your stack is lagging behind current stable release,
//! it may be best to consider locking `test-case` version with `=` in your `Cargo.toml`.
//!
//! # Documentation
//!
//! Most up to date documentation is available in our [wiki](https://github.com/frondeus/test-case/wiki).
pub use test_case_macros::test_case;
pub use test_case_macros::test_case as case;
pub use test_case_macros::test_matrix;

#[cfg(feature = "with-regex")]
pub use regex::*;