macro_rules! assert_fs_read_to_string_is_match {
($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
path_into_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 path = "alfa.txt";
let matcher = Regex::new(r"lf").expect("regex");
assert_fs_read_to_string_is_match!(path, matcher);
// This will panic
let path = "alfa.txt";
let matcher = Regex::new(r"zz").expect("regex");
assert_fs_read_to_string_is_match!(path, matcher);
// assertion failed: `assert_fs_read_to_string_is_match!(path, matcher)`
// https://docs.rs/assertables/…/assertables/macro.assert_fs_read_to_string_is_match.html
// path label: `path`,
// path debug: `\"alfa.txt\"`,
// matcher label: `matcher`,
// matcher debug: `Regex(\"zz\")`,
// string: `\"alfa\\n\"`