Skip to main content

ExpectationList

Struct ExpectationList 

Source
pub struct ExpectationList<'e, T>(/* private fields */);
Expand description

List of expectations on a value.

Implementations§

Source§

impl<'e, T: Debug> ExpectationList<'e, T>

Source

pub fn new() -> Self

Creates a new empty list of expectations.

Source

pub fn push(&mut self, expectation: impl Expectation<T> + 'e)

Add a new expectation to the list.

Source

pub fn check(&self, value: &T) -> CheckResult

Check all expectations on the value.

Runs all expectations in order.

§Returns

CheckResult::Pass if all expectations pass, otherwise CheckResult::Fail with a formatted message. If multiple failures occur, they are concatenated with newlines.

Trait Implementations§

Source§

impl<'e, T: Debug> Default for ExpectationList<'e, T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'e, T> ExpectationBuilder<'e> for ExpectationList<'e, T>
where T: Debug + 'e,

Source§

type Value = T

Target value type for this builder
Source§

fn to_pass(self, expectation: impl Expectation<T> + 'e) -> Self

Expect the value to pass an expectation This is intended to be used in extension methods to add expectations to the builder

Auto Trait Implementations§

§

impl<'e, T> Freeze for ExpectationList<'e, T>

§

impl<'e, T> !RefUnwindSafe for ExpectationList<'e, T>

§

impl<'e, T> !Send for ExpectationList<'e, T>

§

impl<'e, T> !Sync for ExpectationList<'e, T>

§

impl<'e, T> Unpin for ExpectationList<'e, T>

§

impl<'e, T> UnsafeUnpin for ExpectationList<'e, T>

§

impl<'e, T> !UnwindSafe for ExpectationList<'e, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'e, B> BooleanExpectations for B

Source§

fn to_be_true(self) -> B

Expect the value to be true Read more
Source§

fn to_be_false(self) -> B

Expect the value to be false Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<'e, T, U, B> EqualityExpectations<T, U> for B
where T: PartialEq<U> + Debug + 'e, U: Debug + 'e, B: ExpectationBuilder<'e, Value = T>,

Source§

fn to_equal(self, value: U) -> B

Expect the value to equal another value Read more
Source§

impl<'e, T, U, B> ExpectProjection<'e, T, U> for B
where T: Debug + 'e, U: Debug + 'e, B: ExpectationBuilder<'e, Value = T>,

Source§

fn projected_by<F>( self, projection: F, ) -> ProjectedExpectationsBuilder<'e, B, T, U>
where F: Fn(&T) -> U + 'e,

Add expectations on a projected value. Read more
Source§

fn projected_by_ref<F>( self, projection: F, ) -> ProjectedExpectationsBuilder<'e, B, T, U>
where F: for<'a> Fn(&'a T) -> &'a U + 'e,

Add expectations on a projected reference. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<'e, I, C, B> IterableCountExpectations<'e, B> for B
where I: Debug + 'e, &'a I: for<'a> IntoIterator<Item = &'a C>, C: Debug, B: ExpectationBuilder<'e, Value = I>,

Source§

fn count(self) -> impl ExpectationBuilder<'e, Value = usize>

Make expectations on the number of items in the iterable. Read more
Source§

fn to_not_be_empty(self) -> B

Expect an iterable to not be empty. Read more
Source§

fn to_be_empty(self) -> B

Expect an iterable to be empty. Read more
Source§

impl<'e, I, C, B> IterableItemEqualityExpectations<'e, B, C> for B
where I: Debug, &'a I: for<'a> IntoIterator<Item = &'a C>, C: PartialEq + Debug + 'e, B: ExpectationBuilder<'e, Value = I>,

Source§

fn to_contain_equal_to(self, value: C) -> B

Expect an iterable to contain at least one value equal to another value Read more
Source§

fn to_contain_equal_to_all_of(self, values: impl IntoIterator<Item = C>) -> B

Expect an iterable to contain at least one value equal to another value Read more
Source§

fn to_be_equivalent_to(self, values: impl IntoIterator<Item = C>) -> B

Expect an iterable to be equivalent to another iterable Read more
Source§

fn to_be_equivalent_to_in_any_order( self, values: impl IntoIterator<Item = C>, ) -> B

Expect an iterable to be equivalent to another iterable, ignoring the order of items Read more
Source§

impl<'e, T, B> OptionExpectations<'e, T> for B
where T: Debug + 'e, B: ExpectationBuilder<'e, Value = Option<T>>,

Source§

fn to_be_some(self) -> B

Expect the Option to be Some Read more
Source§

fn to_be_none(self) -> B

Expect the Option to be None Read more
Source§

fn to_be_some_matching<F>(self, predicate: F) -> B
where F: Fn(&T) -> bool + 'e,

Expect the Option to be Some and the Some value to match a predicate Read more
Source§

impl<'e, T, B> OrderExpectations<'e, T> for B
where T: PartialOrd + Debug + 'e, B: ExpectationBuilder<'e, Value = T>,

Source§

fn to_be_less_than(self, value: T) -> B

Expect the value to be less than another value Read more
Source§

fn to_be_less_than_or_equal(self, value: T) -> B

Expect the value to be less than or equal to another value Read more
Source§

fn to_be_greater_than(self, value: T) -> B

Expect the value to be greater than another value Read more
Source§

fn to_be_greater_than_or_equal(self, value: T) -> B

Expect the value to be greater than or equal to another value Read more
Source§

fn to_be_inside<R>(self, range: R) -> B
where R: RangeBounds<T> + Debug + 'e,

Expect the value to be inside a range Read more
Source§

impl<'e, T, B> ProjectedOptionExpectations<'e, T> for B
where T: Debug + 'e, B: ExpectationBuilder<'e, Value = Option<T>>,

Source§

fn to_be_some_and(self) -> ProjectedExpectationsBuilder<'e, B, Option<T>, T>

Expect the Option to be Some and then chain into further expectations Read more
Source§

impl<'e, T, E, B> ProjectedResultExpectations<'e, T, E> for B
where T: Debug + 'e, E: Debug + 'e, B: ExpectationBuilder<'e, Value = Result<T, E>>,

Source§

fn to_be_ok_and(self) -> ProjectedExpectationsBuilder<'e, B, Result<T, E>, T>

Expect the Result to be Ok and then chain into further expectations Read more
Source§

fn to_be_err_and(self) -> ProjectedExpectationsBuilder<'e, B, Result<T, E>, E>

Expect the Result to be Err and then chain into further expectations Read more
Source§

impl<'e, T, E, B> ResultExpectations<'e, T, E> for B
where T: Debug + 'e, E: Debug + 'e, B: ExpectationBuilder<'e, Value = Result<T, E>>,

Source§

fn to_be_ok(self) -> B

Expect the Result to be Ok Read more
Source§

fn to_be_err(self) -> B

Expect the Result to be Err Read more
Source§

fn to_be_ok_matching<F>(self, predicate: F) -> B
where F: Fn(&T) -> bool + 'e,

Expect the Result to be Ok and the Ok value to match a predicate Read more
Source§

fn to_be_err_matching<F>(self, predicate: F) -> B
where F: Fn(&E) -> bool + 'e,

Expect the Result to be Err and the Err value to match a predicate Read more
Source§

impl<'e, T, B> StringExpectations<'e, T> for B
where T: AsRef<str> + Debug + 'e, B: ExpectationBuilder<'e, Value = T>,

Source§

fn to_contain(self, substring: &'e str) -> B

Expect that a string contains a substring Read more
Source§

fn to_not_contain(self, substring: &'e str) -> B

Expect that a string does not contain a substring Read more
Source§

fn to_have_length(self, length: usize) -> B

Expect that a string has a specific length Read more
Source§

fn to_start_with(self, prefix: &'e str) -> B

Expect that a string starts with a specific prefix Read more
Source§

fn to_end_with(self, suffix: &'e str) -> B

Expect that a string ends with a specific suffix Read more
Source§

fn to_be_empty(self) -> B

Expect that a string is empty Read more
Source§

fn to_be_all_whitespace(self) -> B

Expect that a string consists entirely of whitespace characters Read more
Source§

fn to_be_alphabetic(self) -> B

Expect that a string consists entirely of alphabetic characters Read more
Source§

fn to_be_numeric(self) -> B

Expect that a string consists entirely of numeric characters Read more
Source§

fn to_be_alphanumeric(self) -> B

Expect that a string consists entirely of alphanumeric characters Read more
Source§

fn length(self) -> impl ExpectationBuilder<'e, Value = usize>

Make expectations on the number of characters of the string. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.