macro_rules! assert_io_read_to_string_is_match {
($a_reader:expr, $b_matcher:expr $(,)?) => { ... };
($a_reader:expr, $b_matcher:expr, $($message:tt)+) => { ... };
}Expand description
Assert a ::std::io::Read read_to_string() is a match to a regex.
Pseudocode:
(reader.read_to_string(a_string) ⇒ a_string) matches matcher
-
If true, return
(a_string, b_string). -
Otherwise, call
panic!with a message and the values of the expressions with their debug representations.
§Examples
use assertables::*;
use regex::Regex;
let reader = "hello".as_bytes();
let matcher = Regex::new(r"ell").expect("regex");
assert_io_read_to_string_is_match!(reader, matcher);
// This will panic
let reader = "hello".as_bytes();
let matcher = Regex::new(r"zz").expect("regex");
assert_io_read_to_string_is_match!(reader, matcher);
// assertion failed: `assert_io_read_to_string_is_match!(a_reader, &matcher)`
// https://docs.rs/assertables/…/assertables/macro.assert_io_read_to_string_is_match.html
// reader label: `reader`,
// reader debug: `[104, 101, 108, 108, 111]`,
// matcher label: `matcher`,
// matcher debug: `Regex(\"zz\")`,
// reader string: `\"hello\"`