Skip to main content

Module matchers

Module matchers 

Source
Expand description

All built-in matchers of this crate are in submodules of this module.

Macros§

all
Matches a value which all of the given matchers match.
any
Matches a value which at least one of the given matchers match.
contains_each
Matches a container containing elements matched by the given matchers.
elements_are
Matches a container’s elements to each matcher in order.
field
Matches a structure or enum with a given field which is matched by a given matcher.
is_contained_in
Matches a container all of whose elements are matched by the given matchers.
matches_pattern
Matches a value according to a pattern of matchers.
pat
An alias for matches_pattern.
pointwise
Generates a matcher which matches a container each of whose elements match the given matcher name applied respectively to each element of the given container.
property
Matches an object which, upon calling the given method on it with the given arguments, produces a value matched by the given inner matcher.
result_of
Matches a value where the result of callable applied to the value matches the inner matcher.
result_of_ref
Matches a value where the reference to the result of callable applied to the value matches the inner matcher.
unordered_elements_are
Matches a container whose elements in any order have a 1:1 correspondence with the provided element matchers.

Structs§

ContainsMatcher
A matcher which matches a container containing one or more elements a given inner Matcher matches.
EqMatcher
A matcher which matches a value equal to expected.
NearMatcher
A matcher which matches floating-point numbers approximately equal to its expected value.
PredicateMatcher
A matcher which applies predicate on the value.
StrMatcher
A matcher which matches equality or containment of a string-like value in a configurable way.

Traits§

StrMatcherConfigurator
Extension trait to configure StrMatcher.

Functions§

anything
Matches anything. This matcher always succeeds.
approx_eq
Matches a value approximately equal to expected.
char_count
Matches a string whose number of Unicode scalars matches expected.
container_eq
Matches a container equal (in the sense of ==) to expected.
contains
Matches an IntoIterator type whose elements contain a value matched by inner.
contains_regex
Matches a string containing a substring which matches the given regular expression.
contains_substring
Matches a string containing a given substring.
derefs_to
Dereferences the actual value and verifies that the returned reference matches the inner matcher.
displays_as
Matches the string representation of types that implement Display.
each
Matches a container all of whose elements are matched by the matcher inner.
emptyDeprecated
This is deprecated. Use is_empty() instead.
ends_with
Matches a string which ends with the given suffix.
eq
Matches a value equal (in the sense of ==) to expected.
err
Matches a Result containing Err with a value matched by inner.
ge
Matches a value greater than or equal to (in the sense of >=) expected.
gt
Matches a value greater (in the sense of >) than expected.
has_entry
Matches a &HashMap containing the given key whose value is matched by the matcher inner.
is_empty
Matches an empty container.
is_false
Matches boolean value false.
is_finite
Matches a floating point value which is Finite.
is_infinite
Matches a floating point value which is Infinite.
is_nan
Matches a floating point value which is NaN.
is_true
Matches boolean value true.
is_utf8_string
Matches a byte sequence which is a UTF-8 encoded string matched by inner.
le
Matches a value less than or equal to (in the sense of <=) expected.
len
Matches a container whose number of elements matches expected.
lt
Matches a value less (in the sense of <) than expected.
matches_regex
Matches a string the entirety of which which matches the given regular expression.
near
Matches a value equal within max_abs_error of expected.
none
Matches an Option containing None.
not
Matches the actual value exactly when the inner matcher does not match.
ok
Matches a Result containing Ok with a value matched by inner.
points_to
Matches a reference pointing to a value matched by the Matcher expected.
predicate
Creates a matcher based on the predicate provided.
some
Matches an Option containing a value matched by inner.
starts_with
Matches a string which starts with the given prefix.
subset_of
Matches a container all of whose items are in the given container superset.
superset_of
Matches a container containing all of the items in the given container subset.