macro_rules! cases {
($ty:ty, $s:ident => $($name:ident => $body:block),* $(,)?) => { ... };
}Expand description
Build a &'static [Case<S>] from case names and inline blocks.
§Declaration
cases! {
$ty:ty, $s:ident => $($name:ident => $body:block),* $(,)?
}§Description
The type and binding $s are written once; each $body is a block that runs as the case
body. Closures must not capture the environment so they coerce to fn(&mut S).
§Example
use suitecase::{cases, run, Case, HookFns, RunConfig};
#[derive(Default)]
struct MySuite {
n: i32,
}
let cases: &[Case<MySuite>] = cases![MySuite, s =>
one => { s.n = 1; },
two => { assert_eq!(s.n, 1); },
];
let mut suite = MySuite::default();
run(&mut suite, cases, RunConfig::all(), &HookFns::default());