pub struct Assert<T> { /* private fields */ }Expand description
A wrapper around some object that can be reasoned about.
Use assert_that! to construct an Assert and then use methods to make some Assertion.
Assertions can be returned from tests and verified by the test framework.
Implementations§
Source§impl<T> Assert<T>
impl<T> Assert<T>
Sourcepub fn as_deref<U>(&self) -> Assert<&U>where
T: Deref<Target = U>,
pub fn as_deref<U>(&self) -> Assert<&U>where
T: Deref<Target = U>,
Converts from Assert<T> or &Assert<T> to Assert<&T::Target> via Deref.
Sourcepub fn map<F, U>(self, f: F) -> Assert<U>where
F: FnOnce(T) -> U,
pub fn map<F, U>(self, f: F) -> Assert<U>where
F: FnOnce(T) -> U,
Maps an Assert<T> to an Assert<U> by applying a function to its contained value.
Sourcepub fn is_equal_to<U>(self, other: U) -> BinaryAssertion<T, U>
pub fn is_equal_to<U>(self, other: U) -> BinaryAssertion<T, U>
Assert that self is equal to other.
Sourcepub fn is_not_equal_to<U>(self, other: U) -> BinaryAssertion<T, U>
pub fn is_not_equal_to<U>(self, other: U) -> BinaryAssertion<T, U>
Assert that self is not equal to other.
Sourcepub fn is_greater_than<U>(self, other: U) -> BinaryAssertion<T, U>
pub fn is_greater_than<U>(self, other: U) -> BinaryAssertion<T, U>
Assert that self is greater than other.
Sourcepub fn is_less_than<U>(self, other: U) -> BinaryAssertion<T, U>
pub fn is_less_than<U>(self, other: U) -> BinaryAssertion<T, U>
Assert that self is less than other.
Sourcepub fn is_greater_than_or_equal_to<U>(self, other: U) -> BinaryAssertion<T, U>
pub fn is_greater_than_or_equal_to<U>(self, other: U) -> BinaryAssertion<T, U>
Assert that self is greater than or equal to other.
Sourcepub fn is_less_than_or_equal_to<U>(self, other: U) -> BinaryAssertion<T, U>
pub fn is_less_than_or_equal_to<U>(self, other: U) -> BinaryAssertion<T, U>
Assert that self is less than or equal to other.
Source§impl Assert<bool>
impl Assert<bool>
Sourcepub const fn is_true(self) -> UnaryAssertion<bool>
pub const fn is_true(self) -> UnaryAssertion<bool>
Assert that self is true.
Sourcepub const fn is_false(self) -> UnaryAssertion<bool>
pub const fn is_false(self) -> UnaryAssertion<bool>
Assert that self is false.
Source§impl<T: Debug> Assert<Option<T>>
impl<T: Debug> Assert<Option<T>>
Sourcepub fn is_some(self) -> UnaryAssertion<Option<T>>
pub fn is_some(self) -> UnaryAssertion<Option<T>>
Assert that self is Some.
Sourcepub fn is_none(self) -> UnaryAssertion<Option<T>>
pub fn is_none(self) -> UnaryAssertion<Option<T>>
Assert that self is None.
Sourcepub fn is_some_and<F, A>(self, f: F) -> UnaryAssertion<Option<T>>
pub fn is_some_and<F, A>(self, f: F) -> UnaryAssertion<Option<T>>
Assert that self is Some and the Some value matches a predicate.
Sourcepub fn is_none_or<F, A>(self, f: F) -> UnaryAssertion<Option<T>>
pub fn is_none_or<F, A>(self, f: F) -> UnaryAssertion<Option<T>>
Assert that self is None or the Some value matches a predicate.
Source§impl<T: Debug, E: Debug> Assert<Result<T, E>>
impl<T: Debug, E: Debug> Assert<Result<T, E>>
Sourcepub fn is_ok(self) -> UnaryAssertion<Result<T, E>>
pub fn is_ok(self) -> UnaryAssertion<Result<T, E>>
Assert that self is Ok.
Sourcepub fn is_err(self) -> UnaryAssertion<Result<T, E>>
pub fn is_err(self) -> UnaryAssertion<Result<T, E>>
Assert that self is Err.
Sourcepub fn is_ok_and<F, A>(self, f: F) -> impl Assertion
pub fn is_ok_and<F, A>(self, f: F) -> impl Assertion
Assert that self is Ok and the Ok value matches a predicate.
Sourcepub fn is_err_and<F, A>(self, f: F) -> UnaryAssertion<Result<T, E>>
pub fn is_err_and<F, A>(self, f: F) -> UnaryAssertion<Result<T, E>>
Assert that self is Err and the Err value matches a predicate.
Source§impl<'a, T> Assert<&'a [T]>
impl<'a, T> Assert<&'a [T]>
Sourcepub fn is_sorted(self) -> UnaryAssertion<&'a [T]>where
T: PartialOrd,
pub fn is_sorted(self) -> UnaryAssertion<&'a [T]>where
T: PartialOrd,
Assert that self is sorted according to PartialOrd::partial_cmp.
Sourcepub fn is_not_sorted(self) -> UnaryAssertion<&'a [T]>where
T: PartialOrd,
pub fn is_not_sorted(self) -> UnaryAssertion<&'a [T]>where
T: PartialOrd,
Assert that self is not sorted according to PartialOrd::partial_cmp.
Sourcepub fn is_sorted_by<'b, F>(self, compare: F) -> UnaryAssertion<&'a [T]>
pub fn is_sorted_by<'b, F>(self, compare: F) -> UnaryAssertion<&'a [T]>
Assert that self is sorted according to the provided comparison function.
Sourcepub fn is_not_sorted_by<'b, F>(self, compare: F) -> UnaryAssertion<&'a [T]>
pub fn is_not_sorted_by<'b, F>(self, compare: F) -> UnaryAssertion<&'a [T]>
Assert that self is not sorted according to the provided comparison function.
Sourcepub fn is_sorted_by_key<'b, F, K>(self, f: F) -> UnaryAssertion<&'a [T]>
pub fn is_sorted_by_key<'b, F, K>(self, f: F) -> UnaryAssertion<&'a [T]>
Assert that self is sorted according to the provided key extraction function.
Sourcepub fn is_not_sorted_by_key<'b, F, K>(self, f: F) -> UnaryAssertion<&'a [T]>
pub fn is_not_sorted_by_key<'b, F, K>(self, f: F) -> UnaryAssertion<&'a [T]>
Assert that self is not sorted according to the provided key extraction function.
Sourcepub const fn is_empty(self) -> UnaryAssertion<&'a [T]>
pub const fn is_empty(self) -> UnaryAssertion<&'a [T]>
Assert that self is empty.
Sourcepub const fn is_not_empty(self) -> UnaryAssertion<&'a [T]>
pub const fn is_not_empty(self) -> UnaryAssertion<&'a [T]>
Assert that self is not empty.
Sourcepub const fn is_len(self, len: usize) -> BinaryAssertion<&'a [T], usize>
pub const fn is_len(self, len: usize) -> BinaryAssertion<&'a [T], usize>
Assert that self has the given length.
Sourcepub const fn is_not_len(self, len: usize) -> BinaryAssertion<&'a [T], usize>
pub const fn is_not_len(self, len: usize) -> BinaryAssertion<&'a [T], usize>
Assert that self does not have the given length.
Sourcepub fn contains(self, elem: T) -> BinaryAssertion<&'a [T], T>where
T: PartialEq,
pub fn contains(self, elem: T) -> BinaryAssertion<&'a [T], T>where
T: PartialEq,
Assert that self contains elem.
Sourcepub fn does_not_contain(self, elem: T) -> BinaryAssertion<&'a [T], T>where
T: PartialEq,
pub fn does_not_contain(self, elem: T) -> BinaryAssertion<&'a [T], T>where
T: PartialEq,
Assert that self does not contain elem.