macro_rules! assert_fs_read_to_string_matches { ($a_path:expr, $b_matcher:expr $(,)?) => { ... }; ($a_path:expr, $b_matcher:expr, $($message:tt)+) => { ... }; }
Expand description
Assert a std::fs::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 path = "alfa.txt";
let matcher = Regex::new(r"alfa").unwrap();
assert_fs_read_to_string_matches!(&path, &matcher);
let path = "alfa.txt";
let matcher = Regex::new(r"zzz").unwrap();
assert_fs_read_to_string_matches!(&path, &matcher);
// assertion failed: `assert_fs_read_to_string_matches!(a_path, matcher)`
// a_path label: `&path`,
// a_path debug: `\"alfa.txt\"`,
// matcher label: `&matcher`,
// matcher debug: `Regex(\"zzz\")`,
// a: `\"alfa\\n\"`,
// b: `Regex(\"zzz\")`