macro_rules! assert_command_stdout_eq_as_result {
($a_command:expr, $b_expr:expr $(,)?) => { ... };
}Expand description
Assert a command stdout string is equal to another.
-
When true, return
(). -
When true, 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 name: `command`,\n",
" right expr name: `s`,\n",
" left command: `\"printf\"`,\n",
" right expr: `\"world\"`,\n",
" left: `\"hello\"`,\n",
" right: `\"world\"`"
);
assert_eq!(actual, expect);