[−][src]Attribute Macro ntest_test_cases::test_case
#[test_case]
Test cases can be used to have multiple inputs for a given function. With the test_case attribute multiple tests will be generated using the Procedural Macros capabilities of rust.
The function input can be of type int
, bool
, or str
.
WARNING!
It is currently not possible to have negative numbers as macro input. For example
this #[test_case(-13)]
will not work.
Examples
Example with a single argument
ⓘThis example is not tested
#[test_case(13)] #[test_case(42)] fn one_arg(x: u32) { assert!(x == 13 || x == 42) }
Example with multiple arguments:
ⓘThis example is not tested
#[test_case(true, "true", 1)] fn test_mix(x: bool, y: &str, z: u16) { assert!(x); assert_eq!(y, "true"); assert_eq!(z, 1); }