Function googletest::matchers::matches_regex
source ยท pub fn matches_regex<PatternT: Deref<Target = str>>(
pattern: PatternT,
) -> MatchesRegexMatcher<PatternT>
Expand description
Matches a string the entirety of which which matches the given regular expression.
This is similar to contains_regex
,
except that the match must cover the whole string and not a substring.
Both the actual value and the expected regular expression may be either a
String
or a string reference.
verify_that!("Some value", matches_regex("S.*e"))?; // Passes
verify_that!("Another value", matches_regex("Some"))?; // Fails
verify_that!("Some value", matches_regex("Some"))?; // Fails
verify_that!("Some value".to_string(), matches_regex(".*v.*e"))?; // Passes
verify_that!("Some value", matches_regex(".*v.*e".to_string()))?; // Passes
Panics if the given pattern
is not a syntactically valid regular
expression.