macro_rules! assert_program_args_stdout_eq_other {
($a_program:expr, $a_args:expr, $b_program:expr, $b_args:expr $(,)?) => { ... };
($a_program:expr, $a_args:expr, $b_program:expr, $($message:tt)+) => { ... };
}Expand description
Assert a command (built with program and args) stdout string is equal to another.
-
If true, return
(). -
Otherwise, call
panic!with a message and the values of the expressions with their debug representations.
Examples
// Return Ok
let a_program = "printf";
let a_args = ["%s", "hello"];
let b_program = "printf";
let b_args = ["%s%s%s%s%s", "h", "e", "l", "l", "o"];
assert_program_args_stdout_eq_other!(&a_program, &a_args, &b_program, &b_args);
//-> ()
// Panic with error message
let result = panic::catch_unwind(|| {
let a_program = "printf";
let a_args = ["%s", "hello"];
let b_program = "printf";
let b_args = ["%s%s%s%s%s", "w", "o", "r", "l", "d"];
assert_program_args_stdout_eq_other!(&a_program, &a_args, &b_program, &b_args);
//-> panic!
});
assert!(result.is_err());
let actual = result.unwrap_err().downcast::<String>().unwrap().to_string();
let expect = concat!(
"assertion failed: `assert_program_args_stdout_eq_other!(left_program, left_args, right_program, right_args)`\n",
" left_program label: `&a_program`,\n",
" left_program debug: `\"printf\"`,\n",
" left_args label: `&a_args`,\n",
" left_args debug: `[\"%s\", \"hello\"]`,\n",
" right_program label: `&b_program`,\n",
" right_program debug: `\"printf\"`,\n",
" right_args label: `&b_args`,\n",
" right_args debug: `[\"%s%s%s%s%s\", \"w\", \"o\", \"r\", \"l\", \"d\"]`,\n",
" left: `\"hello\"`,\n",
" right: `\"world\"`"
);
assert_eq!(actual, expect);