Skip to main content

assert_text_match

Macro assert_text_match 

Source
macro_rules! assert_text_match {
    ($left: expr, $right: expr $(,)?) => { ... };
    ($left: expr, $right: expr, $($arg:tt)+) => { ... };
}
Expand description

Asserts that the first text expression matches the given regular expression.

If the text does not match the regex, it panics.

§Arguments

  • $left - The text expression to check.
  • $right - The regular expression string.

§Panics

Panics if the $right string is not a valid regular expression.

§Examples

use assert_text::assert_text_match;
assert_text_match!("hello world", r"^h.+d$");
use assert_text::assert_text_match;
assert_text_match!("hello world", r"^goodbye.*");
use assert_text::assert_text_match;
assert_text_match!("hello world", r"^goodbye.*", "custom message: {}", "foo");