macro_rules! assert_io_read_to_string_matches { ($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.
-
If true, return
(). -
Otherwise, call
panic!with a message and the values of the expressions with their debug representations.
§Examples
use std::io::Read;
use regex::Regex;
let mut reader = "hello".as_bytes();
let matcher = Regex::new(r"ell").unwrap();
assert_io_read_to_string_matches!(reader, &matcher);
let mut reader = "hello".as_bytes();
let matcher = Regex::new(r"zzz").unwrap();
assert_io_read_to_string_matches!(reader, &matcher);
// assertion failed: `assert_io_read_to_string_matches!(a_reader, &matcher)`
// reader label: `reader`,
// reader debug: `[]`,
// matcher label: `&matcher`,
// matcher debug: `Regex(\"zzz\")`,
// reader string: `\"hello\"`