assert_is_match

Macro assert_is_match 

Source
macro_rules! assert_is_match {
    ($matcher:expr, $matchee:expr $(,)?) => { ... };
    ($matcher:expr, $matchee:expr, $($message:tt)+) => { ... };
}
Expand description

Assert a matcher is a match for an expression.

Pseudocode:
a.is_match(b)

  • If true, return ().

  • Otherwise, call panic! with a message and the values of the expressions with their debug representations.

§Examples

use assertables::*;
use regex::Regex;

let a = Regex::new(r"lf").expect("regex");
let b = "alfa";
assert_is_match!(a, b);

// This will panic
let a = Regex::new(r"xx").expect("regex");
let b = "alfa";
assert_is_match!(a, b);
// assertion failed: `assert_is_match!(matcher, matchee)`
// https://docs.rs/assertables/…/assertables/macro.assert_is_match.html
//  matcher label: `a`,
//  matcher debug: `Regex(\"xx\")`,
//  matchee label: `b`,
//  matchee debug: `\"alfa\"`

§Module macros