Crate xpct

Source
Expand description

xpct is an extensible test assertion library for Rust.

It’s designed to be ergonomic, batteries-included, and test framework agnostic.

If you’re new here, you may want to check out the Tutorial and the rest of the User Docs.

Modules§

core
Core types for the library.
docsdocsrs
User Docs
format
The formatters provided by this crate.
matchers
The matchers provided by this crate.

Macros§

expect
Make an assertion.
fields
Apply matchers to multiple struct fields.
pattern
Construct a new Pattern value from a match pattern.

Structs§

Error
An error that occurs in a matcher.

Functions§

all
Succeeds when all of the passed matchers succeed.
any
Succeeds when any of the passed matchers succeed.
approx_eq_f32float
Succeeds when the actual f32 value approximately equals the expected f32 value.
approx_eq_f64float
Succeeds when the actual f64 value approximately equals the expected f64 value.
approx_eq_time
Succeeds when the actual time approximately equals the expected time.
be_default
Succeeds when the actual value equals the default value for the type.
be_directory
Succeeds when the actual value is the path of an existing directory.
be_empty
Succeeds when the actual value is empty.
be_err
Succeeds when the actual value is Err.
be_existing_file
Succeeds when the actual value is the path of an existing file.
be_false
Succeeds when the actual value is false.
be_ge
Succeeds when the actual value is greater than or equal to the expected value.
be_gt
Succeeds when the actual value is greater than the expected value.
be_in
Succeeds when the actual value is contained in the expected collection.
be_le
Succeeds when the actual value is less than or equal to the expected value.
be_lt
Succeeds when the actual value is less than the expected value.
be_none
Succeeds when the actual value is None.
be_ok
Succeeds when the actual value is Ok.
be_regular_file
Succeeds when the actual value is the path of an existing regular file.
be_some
Succeeds when the actual value is Some.
be_sorted_asc
Succeeds when the actual value is sorted in ascending order.
be_sorted_by
Succeeds when the actual value is sorted according to the given predicate.
be_sorted_desc
Succeeds when the actual value is sorted in descending order.
be_symlink
Succeeds when the actual value is the path of an existing symbolic link.
be_true
Succeeds when the actual value is true.
be_zero
Succeeds when the actual integer value is 0.
consist_of
Succeeds when the actual value contains exactly the given elements, in any order.
contain_element
Succeeds when the actual value contains the given element.
contain_elements
Succeeds when the actual value contains all the given elements.
contain_substr
Succeeds when the actual value contains the expected substring.
each
Succeeds when each of the passed matchers succeeds.
eq_casefoldcasefold
Succeeds when the actual string equals the expected string regardless of case.
eq_diffdiff
Succeeds when the actual value equals the expected value and shows a diff otherwise.
equal
Succeeds when the actual value equals the expected value.
every
Succeeds when the matcher succeeds for every element of the actual value.
have_len
Succeeds when the actual value has the given length.
have_prefix
Succeeds when the actual value has the expected prefix.
have_suffix
Succeeds when the actual value has the expected suffix.
into
Infallibly convert the input value via From/Into.
iter_map
Infallibly map each value of an iterator by applying a function to it.
iter_try_map
Fallibly map each value of an iterator by applying a function to it.
map
Infallibly map the input value by applying a function to it.
match_any_fields
Succeeds when any of the fields of a struct succeed.
match_elements
Tests each element of the actual value against a different matcher.
match_fields
Succeeds when all the fields of a struct succeed.
match_jsonjson
Succeeds when the actual string and the expected string are equivalent JSON.
match_pattern
Succeeds when the given pattern matches.
match_regexregex
Succeeds when the actual value matches the given regular expression.
not
Negates the matcher passed to it.
try_into
Fallibly convert the input value via TryFrom/TryInto.
try_map
Fallibly map the input value by applying a function to it.
why
Attaches a context string to a matcher that will appear in the failure output.
why_lazy
Attaches a lazily evaluated context string to a matcher that will appear in the failure output.

Type Aliases§

Result
A result type for Error.