macro_rules! assert_command_stderr_eq_as_result {
($a_command:expr, $b_expr:expr $(,)?) => { ... };
}Expand description
Assert a command stderr string is equal to an expression.
-
If true, return Result
Ok(()). -
Otherwise, return Result
Errwith a diagnostic message.
Examples
use std::process::Command;
let mut command = Command::new("printf");
let s = "usage: printf format [arguments ...]\n";
let x = assert_command_stderr_eq_as_result!(command, s);
//-> Ok(())
let actual = x.unwrap();
let expect = ();
assert_eq!(actual, expect);
let mut command = Command::new("printf");
let s = "hello";
let x = assert_command_stderr_eq_as_result!(command, s);
//-> Err(…)
let actual = x.unwrap_err();
let expect = concat!(
"assertion failed: `assert_command_stderr_eq!(left_command, right_expr)`\n",
" left_command label: `command`,\n",
" left_command debug: `\"printf\"`,\n",
" right_expr label: `s`,\n",
" right_expr debug: `\"hello\"`,\n",
" left: `\"usage: printf format [arguments ...]\\n\"`,\n",
" right: `\"hello\"`"
);
assert_eq!(actual, expect);