macro_rules! assert_program_args_stdout_eq_as_result {
($a_program:expr, $a_args:expr, $b_expr:expr $(,)?) => { ... };
}Expand description
Assert a command (built with program and args) stdout string is equal to an expression.
-
If true, return Result
Ok(()). -
Otherwise, return Result
Errwith a diagnostic message.
Examples
let program = "printf";
let args = ["%s", "hello"];
let s = "hello";
let x = assert_program_args_stdout_eq_as_result!(&program, &args, s);
//-> Ok(())
let actual = x.unwrap();
let expect = ();
assert_eq!(actual, expect);
let program = "printf";
let args = ["%s", "hello"];
let s = "world";
let x = assert_program_args_stdout_eq_as_result!(&program, &args, s);
//-> Err(…)
let actual = x.unwrap_err();
let expect = concat!(
"assertion failed: `assert_program_args_stdout_eq!(left_program, left_args, right_expr)`\n",
" left_program label: `&program`,\n",
" left_program debug: `\"printf\"`,\n",
" left_args label: `&args`,\n",
" left_args debug: `[\"%s\", \"hello\"]`,\n",
" right_expr label: `s`,\n",
" right_expr debug: `\"world\"`,\n",
" left: `\"hello\"`,\n",
" right: `\"world\"`"
);
assert_eq!(actual, expect);