Function googletest::matchers::contains_substring
source · pub fn contains_substring<A: ?Sized, T>(expected: T) -> StrMatcher<A, T>
Expand description
Matches a string containing a given substring.
Both the actual value and the expected substring may be either a String
or
a string reference.
verify_that!("Some value", contains_substring("Some"))?; // Passes
verify_that!("Another value", contains_substring("Some"))?; // Fails
verify_that!("Some value".to_string(), contains_substring("value"))?; // Passes
verify_that!("Some value", contains_substring("value".to_string()))?; // Passes
See the StrMatcherConfigurator
extension trait for more options on how
the string is matched.
Note on memory use: In most cases, this matcher does not allocate memory when matching strings. However, it must allocate copies of both the actual and expected values when matching strings while
ignoring_ascii_case
is set.