macro_rules! assert_command_stdout_eq_x {
($a_command:expr, $b_expr:expr $(,)?) => { ... };
($a_command:expr, $b_expr:expr, $($message:tt)+) => { ... };
}Expand description
Assert a command stdout string is equal to an expression.
Pseudocode:
(command ⇒ stdout) = (expr into string)
-
If true, return
(stdout). -
Otherwise, call
panic!with a message and the values of the expressions with their debug representations.
§Examples
use assertables::*;
use std::process::Command;
let mut command = Command::new("bin/printf-stdout");
command.args(["%s", "alfa"]);
let bytes = vec![b'a', b'l', b'f', b'a'];
assert_command_stdout_eq_x!(command, bytes);
// This will panic
let mut command = Command::new("bin/printf-stdout");
command.args(["%s", "alfa"]);
let bytes = vec![b'z', b'z'];
assert_command_stdout_eq_x!(command, bytes);
// assertion failed: `assert_command_stdout_eq_x!(command, expr)`
// https://docs.rs/assertables/…/assertables/macro.assert_command_stdout_eq_x.html
// command label: `command`,
// command debug: `\"bin/printf-stdout\" \"%s\" \"alfa\"`,
// command value: `[97, 108, 102, 97]`,
// expr label: `bytes`,
// expr debug: `[122, 122]`,
// expr value: `[122, 122]`