macro_rules! assert_program_args_stderr_ge_expr { ($a_program:expr, $a_args:expr, $b_expr:expr $(,)?) => { ... }; ($a_program:expr, $a_args:expr, $b_expr:expr, $($message:tt)+) => { ... }; }
Expand description
Assert a command (built with program and args) stderr string is greater than or equal to an expression.
-
If true, return
(). -
Otherwise, call
panic!with a message and the values of the expressions with their debug representations.
§Examples
// Return Ok because a > b
let program = "bin/printf-stderr";
let args = ["%s", "hello"];
let s = String::from("hallo");
assert_program_args_stderr_ge_expr!(&program, &args, s);
//-> ()
// Return Ok because a == b
let program = "bin/printf-stderr";
let args = ["%s", "hello"];
let s = String::from("hello");
assert_program_args_stderr_ge_expr!(&program, &args, s);
//-> ()
// Panic with error message
let result = panic::catch_unwind(|| {
let program = "bin/printf-stderr";
let args = ["%s", "hello"];
let s = String::from("hullo");
assert_program_args_stderr_ge_expr!(&program, &args, s);
//-> panic!
});
assert!(result.is_err());
let actual = result.unwrap_err().downcast::<String>().unwrap().to_string();
let expect = concat!(
"assertion failed: `assert_program_args_stderr_ge_expr!(a_program, a_args, b_expr)`\n",
" a_program label: `&program`,\n",
" a_program debug: `\"bin/printf-stderr\"`,\n",
" a_args label: `&args`,\n",
" a_args debug: `[\"%s\", \"hello\"]`,\n",
" b_expr label: `s`,\n",
" b_expr debug: `\"hullo\"`,\n",
" a: `\"hello\"`,\n",
" b: `\"hullo\"`"
);
assert_eq!(actual, expect);