Trait googletest::matcher::Matcher
source · pub trait Matcher<T: Debug + ?Sized> {
fn matches(&self, actual: &T) -> MatcherResult;
fn describe(&self, matcher_result: MatcherResult) -> String;
fn explain_match(&self, actual: &T) -> MatchExplanation { ... }
}Expand description
An interface for checking an arbitrary condition on a datum.
Required Methods§
sourcefn matches(&self, actual: &T) -> MatcherResult
fn matches(&self, actual: &T) -> MatcherResult
Returns whether the condition matches the datum actual.
The trait implementation defines what it means to “match”. Often the
matching condition is based on data stored in the matcher. For example,
eq matches when its stored expected value is equal (in the sense of
the == operator) to the value actual.
sourcefn describe(&self, matcher_result: MatcherResult) -> String
fn describe(&self, matcher_result: MatcherResult) -> String
Returns a description of self or a negative description if
matcher_result is DoesNotMatch.
The function should print a verb phrase that describes the property a value matching, respectively not matching, this matcher should have. The subject of the verb phrase is the value being matched.
For example, eq(7).describe(MatcherResult::Matches) prints “is equal to 7”.
Provided Methods§
sourcefn explain_match(&self, actual: &T) -> MatchExplanation
fn explain_match(&self, actual: &T) -> MatchExplanation
Prepares a MatchExplanation describing how the expected value
encoded in this instance matches or does not match the given value
actual.
The default implementation relies on [Describe::describe].