Macro assertables::assert_program_args_stdout_lt

source ·
macro_rules! assert_program_args_stdout_lt {
    ($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 less than 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 = "bin/printf-stdout";
let a_args = ["%s", "hello"];
let b_program = "bin/printf-stdout";
let b_args = ["%s%s%s%s%s", "h", "u", "l", "l", "o"];
assert_program_args_stdout_lt!(&a_program, &a_args, &b_program, &b_args);
//-> ()

// Panic with error message
let result = panic::catch_unwind(|| {
let a_program = "bin/printf-stdout";
let a_args = ["%s", "hello"];
let b_program = "bin/printf-stdout";
let b_args = ["%s%s%s%s%s", "h", "a", "l", "l", "o"];
assert_program_args_stdout_lt!(&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_lt!(a_program, a_args, b_program, b_args)`\n",
    " a_program label: `&a_program`,\n",
    " a_program debug: `\"bin/printf-stdout\"`,\n",
    "    a_args label: `&a_args`,\n",
    "    a_args debug: `[\"%s\", \"hello\"]`,\n",
    " b_program label: `&b_program`,\n",
    " b_program debug: `\"bin/printf-stdout\"`,\n",
    "    b_args label: `&b_args`,\n",
    "    b_args debug: `[\"%s%s%s%s%s\", \"h\", \"a\", \"l\", \"l\", \"o\"]`,\n",
    "               a: `\"hello\"`,\n",
    "               b: `\"hallo\"`"
);
assert_eq!(actual, expect);

§Module macros