macro_rules! assert_program_args_stdout_contains { ($a_program:expr, $a_args:expr, $containee:expr $(,)?) => { ... }; ($a_program:expr, $a_args:expr, $containee:expr, $($message:tt)+) => { ... }; }
Expand description
Assert a command (built with program and args) stdout string contains a given containee.
Pseudocode:
(program1 + args1 ⇒ command ⇒ stdout ⇒ string) contains (expr into string)
-
If true, return
()
. -
Otherwise, call
panic!
with a message and the values of the expressions with their debug representations.
This uses std::String
method contains
.
- The containee can be a &str, char, a slice of chars, or a function or closure that determines if a character contains.
§Examples
let program = "bin/printf-stdout";
let args = ["%s", "hello"];
let containee = "ell";
assert_program_args_stdout_contains!(&program, &args, &containee);
let program = "bin/printf-stdout";
let args = ["%s", "hello"];
let containee = "zzz";
assert_program_args_stdout_contains!(&program, &args, &containee);
// assertion failed: `assert_program_args_stdout_contains!(a_program, a_args, containee)`
// https://docs.rs/assertables/8.7.0/assertables/macro.assert_program_args_stdout_contains.html
// a_program label: `&program`,
// a_program debug: `\"bin/printf-stdout\"`,
// a_args label: `&args`,
// a_args debug: `[\"%s\", \"hello\"]`,
// containee label: `&containee`,
// containee debug: `\"zzz\"`,
// a: `\"hello\"`,
// b: `\"zzz\"`