macro_rules! assert_fs_read_to_string_matches { ($path:expr, $matcher:expr $(,)?) => { ... }; ($path:expr, $matcher:expr, $($message:tt)+) => { ... }; }
Expand description
Assert a std::fs::read_to_string(path) is a match to a regex.
Pseudocode:
std::fs::read_to_string(path) matches expr
-
If true, return
(). -
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 path = "alfa.txt";
let matcher = Regex::new(r"alfa").unwrap();
assert_fs_read_to_string_matches!(&path, &matcher);
// This will panic
let path = "alfa.txt";
let matcher = Regex::new(r"zz").unwrap();
assert_fs_read_to_string_matches!(&path, &matcher);
// assertion failed: `assert_fs_read_to_string_matches!(path, matcher)`
// https://docs.rs/assertables/8.18.0/assertables/macro.assert_fs_read_to_string_matches.html
// path label: `&path`,
// path debug: `\"alfa.txt\"`,
// matcher label: `&matcher`,
// matcher debug: `Regex(\"zz\")`,
// read string: `\"alfa\\n\"`