Macro lib::assert_fs_read_to_string_matches

source ·
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() 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!(path, matcher)`
//     path label: `&path`,
//     path debug: `\"alfa.txt\"`,
//  matcher label: `&matcher`,
//  matcher debug: `Regex(\"zzz\")`,
//    read string: `\"alfa\\n\"`

§Module macros