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 std::io::Read;
use regex::Regex;
let mut 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 mut 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/9.5.3/assertables/macro.assert_io_read_to_string_is_match.html
// reader label: `reader`,
// reader debug: `[]`,
// matcher label: `&matcher`,
// matcher debug: `Regex(\"zz\")`,
// reader size: `5`
// reader string: `\"hello\"`