macro_rules! assert_program_args_stdout_eq_other_as_result {
    ($a_program:expr, $a_args:expr, $b_program:expr, $b_args:expr $(,)?) => { ... };
}
Expand description

Assert a command (built with program and args) stdout string is equal to another.

  • If true, return ().

  • If true, return Result Err 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"];
let x = assert_program_args_stdout_eq_other_as_result!(&a_program, &a_args, &b_program, &b_args);
//-> Ok(())
assert_eq!(x, Ok(()));
let actual = x.unwrap();
let expect = ();
assert_eq!(actual, expect);

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"];
let x = assert_program_args_stdout_eq_other_as_result!(&a_program, &a_args, &b_program, &b_args);
//-> Err(…)
assert!(x.is_err());
let actual = x.unwrap_err();
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);