assertables

Macro assert_command_stdout_string_contains

Source
macro_rules! assert_command_stdout_string_contains {
    ($command:expr, $containee:expr $(,)?) => { ... };
    ($command:expr, $containee:expr, $($message:tt)+) => { ... };
}
Expand description

Assert a command stdout string contains a given containee.

Pseudocode:
(command ⇒ stdout ⇒ string) contains (expr into string)

  • If true, return (command ⇒ stdout ⇒ string).

  • Otherwise, call panic! with a message and the values of the expressions with their debug representations.

This uses ::std::String method contains.

  • The containee can be a &str, char, a slice of chars, or a function or closure that determines if a character contains.

§Examples

use assertables::*;
use std::process::Command;

let mut command = Command::new("bin/printf-stdout");
command.args(["%s", "alfa"]);
let containee = "lf";
assert_command_stdout_string_contains!(command, &containee);

// This will panic
let mut command = Command::new("bin/printf-stdout");
command.args(["%s", "alfa"]);
let containee = "zz";
assert_command_stdout_string_contains!(command, &containee);
// assertion failed: `assert_command_stdout_string_contains!(command, containee)`
// https://docs.rs/assertables/9.4.0/assertables/macro.assert_command_stdout_string_contains.html
//    command label: `command`,
//    command debug: `\"bin/printf-stdout\" \"%s\" \"alfa\"`,
//  containee label: `&containee`,
//  containee debug: `\"zz\"`,
//           string: `\"alfa\"`

§Module macros