macro_rules! assert_command_stdout_eq_as_result {
($a_command:expr, $b_expr:expr $(,)?) => { ... };
}Expand description
Assert a command stdout 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");
command.args(["%s", "hello"]);
let s = "hello";
let x = assert_command_stdout_eq_as_result!(command, s);
//-> Ok(())
let actual = x.unwrap();
let expect = ();
assert_eq!(actual, expect);
let mut command = Command::new("printf");
command.args(["%s", "hello"]);
let s = "world";
let x = assert_command_stdout_eq_as_result!(command, s);
//-> Err(…)
let actual = x.unwrap_err();
let expect = concat!(
"assertion failed: `assert_command_stdout_eq!(left_command, right_expr)`\n",
" left_command label: `command`,\n",
" left_command debug: `\"printf\" \"%s\" \"hello\"`,\n",
" right_expr label: `s`,\n",
" right_expr debug: `\"world\"`,\n",
" left: `\"hello\"`,\n",
" right: `\"world\"`"
);
assert_eq!(actual, expect);