Struct assertor::Subject

source ·
pub struct Subject<'a, Sub, Opt, Ret> { /* private fields */ }
Expand description

Data structure that contains a value to be tested (actual value) with auxiliary data (ex. line pos, description).

Implementations§

source§

impl<'a, Sub, Opt, Ret> Subject<'a, Sub, Opt, Ret>

source

pub fn new( actual: &'a Sub, expr: String, description: Option<String>, option: Opt, location: Option<Location>, return_type: PhantomData<Ret>, ) -> Self

Creates a new subject with a referenced actual value.

Trait Implementations§

source§

impl<R> BooleanAssertion<R> for Subject<'_, bool, (), R>

source§

fn is_true(&self) -> R

Checks that the subject is equal to true.
source§

fn is_false(&self) -> R

Checks that the subject is equal to false.
source§

impl<'a, R> CheckThatResultAssertion<'a, R> for Subject<'a, CheckThatResult, (), R>

source§

fn facts_are<B: Borrow<Vec<Fact>>>(&self, expected: B) -> R

Checks that the assertion result contains elements of facts in order.
source§

fn facts_are_at_least<B: Borrow<Vec<Fact>>>(&self, facts: B) -> R

Checks that the assertion result contains elements of facts in order.
source§

fn fact_value_for_key<I: Into<String>>( &self, key: I, ) -> Subject<'_, String, (), R>

Returns the first fact value whose key is equal to key.
source§

fn fact_keys(&self) -> Subject<'_, HashSet<&String>, (), R>

Returns keys of the assertion messages.
source§

impl<S: PartialOrd + Debug, R> ComparableAssertion<S, R> for Subject<'_, S, (), R>

source§

fn is_at_least<B: Borrow<S>>(&self, expected: B) -> R

Checks that the subject is greater than or equal to expected.
source§

fn is_at_most<B: Borrow<S>>(&self, expected: B) -> R

Checks that the subject is less than or equal to expected.
source§

fn is_greater_than<B: Borrow<S>>(&self, expected: B) -> R

Checks that the subject is greater than expected.
source§

fn is_less_than<B: Borrow<S>>(&self, expected: B) -> R

Checks that the subject is less than expected.
source§

impl<'a, T, Y, R> CowAssertion<T, Y, R> for Subject<'a, Cow<'a, T>, (), R>
where T: ToOwned<Owned = Y> + ?Sized, AssertionResult: AssertionStrategy<R>,

source§

fn is_borrowed(&self) -> R

Checks that the subject is Cow::Borrowed(_).
source§

fn is_owned(&self) -> R

Checks that the subject is Cow::Owned(_).
source§

fn deref(&self) -> Subject<'_, Y, (), R>

Returns a new subject which is the dereferenced value of the subject. Read more
source§

impl<S: PartialEq + Debug, R> EqualityAssertion<S, R> for Subject<'_, S, (), R>

source§

fn is_equal_to<B: Borrow<S>>(&self, expected: B) -> R

Checks if the subject is equal to expected.
source§

fn is_not_equal_to<B: Borrow<S>>(&self, expected: B) -> R

Checks if the subject value is NOT equal to expected.
source§

impl<'a, S, R: 'a> FloatAssertion<'a, S, R> for Subject<'a, S, (), R>

source§

fn with_rel_tol(self, rel_tol: S) -> Subject<'a, S, FloatTolerance<S>, R>

Set the relative tolerance.
source§

fn with_abs_tol(self, abs_tol: S) -> Subject<'a, S, FloatTolerance<S>, R>

Set the absolute tolerance.
source§

fn is_approx_equal_to<B: Borrow<S>>(&self, expected: B) -> R
where FloatTolerance<S>: Default,

Checks the subject is equal to expected with tolerance. Read more
source§

impl<'a, S, R> FloatAssertion<'a, S, R> for Subject<'a, S, FloatTolerance<S>, R>

source§

fn with_rel_tol(self, rel_tol: S) -> Subject<'a, S, FloatTolerance<S>, R>

Set the relative tolerance.
source§

fn with_abs_tol(self, abs_tol: S) -> Subject<'a, S, FloatTolerance<S>, R>

Set the absolute tolerance.
source§

fn is_approx_equal_to<B: Borrow<S>>(&self, expected: B) -> R

Checks the subject is equal to expected with tolerance. Read more
source§

impl<'a, S, T, R> IteratorAssertion<'a, S, T, R> for Subject<'a, S, (), R>
where S: Iterator<Item = T> + Clone, AssertionResult: AssertionStrategy<R>,

source§

fn contains<B>(&self, element: B) -> R
where B: Borrow<T>, T: PartialEq + Debug,

Checks that the subject iterator contains the element expected. Read more
source§

fn does_not_contain<B>(&self, element: B) -> R
where B: Borrow<T>, T: PartialEq + Debug,

Checks that the subject iterator does not contains the element expected. Read more
source§

fn contains_exactly<EI: Iterator<Item = T> + Clone>( self, expected_iter: EI, ) -> R
where T: PartialEq + Debug,

Checks that the subject exactly contains elements of expected_iter. Read more
source§

fn contains_exactly_in_order<EI: Iterator<Item = T> + Clone>( self, expected_iter: EI, ) -> R
where T: PartialEq + Debug,

Checks that the subject exactly contains elements of expected_iter in the same order. Read more
source§

fn contains_all_of<EI: Iterator<Item = T> + Clone>(self, expected_iter: EI) -> R
where T: PartialEq + Debug,

Checks that the subject contains at least all elements of expected_iter. Read more
source§

fn does_not_contain_any<EI: Iterator<Item = T> + Clone>( &self, elements: EI, ) -> R
where T: PartialEq + Debug,

Checks that the subject does not contains any elements of elements. Read more
source§

fn contains_all_of_in_order<EI: Iterator<Item = T> + Clone>( self, expected_iter: EI, ) -> R
where T: PartialEq + Debug,

Checks that the subject contains at least all elements of expected_iter in the same order. Read more
source§

fn is_empty(&self) -> R
where T: Debug,

Checks that the subject is empty. Read more
source§

fn is_not_empty(&self) -> R
where T: Debug,

Checks that the subject is not empty. Read more
source§

fn has_length(&self, length: usize) -> R
where T: Debug,

Checks that the subject has the given length. Read more
source§

impl<'a, K, V, ML, R> MapAssertion<'a, K, V, ML, R> for Subject<'a, ML, (), R>
where AssertionResult: AssertionStrategy<R>, K: 'a + Eq, ML: MapLike<K, V>,

source§

fn has_length(&self, length: usize) -> R

Checks that the subject has the given length.
source§

fn is_empty(&self) -> R
where K: Debug,

Checks that the subject is empty.
source§

fn is_not_empty(&self) -> R
where K: Debug,

Checks that the subject is not empty.
source§

fn contains_key<BK>(&self, key: BK) -> R
where BK: Borrow<K>, K: Eq + Hash + Debug,

Checks that the subject has the given key.
source§

fn does_not_contain_key<BK>(&self, key: BK) -> R
where BK: Borrow<K>, K: Eq + Hash + Debug,

Checks that the subject does not have the given key.
source§

fn contains_entry<BK, BV>(&self, key: BK, value: BV) -> R
where BK: Borrow<K>, BV: Borrow<V>, K: Eq + Hash + Debug, V: Eq + Debug,

Checks that the subject has entry with the given key and value.
source§

fn does_not_contain_entry<BK, BV>(&self, key: BK, value: BV) -> R
where BK: Borrow<K>, BV: Borrow<V>, K: Eq + Hash + Debug, V: Eq + Debug,

Checks that the subject does not contain entry with the given key and value.
source§

fn contains_at_least<BM, OML>(&self, expected: BM) -> R
where K: Eq + Hash + Debug, V: Eq + Debug, OML: MapLike<K, V> + 'a, BM: Borrow<OML> + 'a,

Checks that the subject contains all entries from expected.
source§

fn does_not_contain_any<BM, OML>(&self, expected: BM) -> R
where K: Eq + Hash + Debug, V: Eq + Debug, OML: MapLike<K, V> + 'a, BM: Borrow<OML> + 'a,

Checks that the subject does not contain any entries from expected.
source§

fn contains_exactly<BM, OML>(&self, expected: BM) -> R
where K: Eq + Hash + Debug, V: Eq + Debug, OML: MapLike<K, V> + 'a, BM: Borrow<OML> + 'a,

Checks that the subject contains only entries from expected.
source§

fn key_set<'b>(&'b self) -> Subject<'_, ML::It<'b>, (), R>
where K: 'b,

Returns a new subject which is an key set of the subject and which implements crate::IteratorAssertion. Read more
source§

impl<T, R> OptionAssertion<T, R> for Subject<'_, Option<T>, (), R>

source§

fn is_none(&self) -> R
where T: PartialEq + Debug,

Checks the subject is Option::None.
source§

fn is_some(&self) -> R
where T: PartialEq + Debug,

Checks the subject is Option::Some(_).
source§

fn has_value<B>(&self, expected: B) -> R
where B: Borrow<T>, T: PartialEq + Debug,

Checks the subject is Option::Some(expected).
source§

fn some(&self) -> Subject<'_, T, (), R>
where T: PartialEq + Debug,

Returns a new subject which is the value of the subject if the subject is Option::Some(_). Otherwise, it fails. Read more
source§

impl<'a, K, V, ML, R> OrderedMapAssertion<'a, K, V, ML, R> for Subject<'a, ML, (), R>
where AssertionResult: AssertionStrategy<R>, K: 'a + Eq + Ord, ML: OrderedMapLike<K, V>,

source§

fn contains_exactly_in_order<BM, OML>(&self, expected: BM) -> R
where K: Eq + Ord + Debug, V: Eq + Debug, OML: OrderedMapLike<K, V> + 'a, BM: Borrow<OML> + 'a,

Checks that the subject exactly contains expected in the same order.
source§

fn contains_all_of_in_order<BM, OML>(&self, expected: BM) -> R
where K: Eq + Ord + Debug, V: Eq + Debug, OML: OrderedMapLike<K, V> + 'a, BM: Borrow<OML> + 'a,

Checks that the subject contains at least all elements of expected in the same order.
source§

impl<'a, T, R, ST> OrderedSetAssertion<'a, ST, T, R> for Subject<'a, ST, (), R>
where AssertionResult: AssertionStrategy<R>, T: Eq + PartialOrd + Debug, ST: OrderedSetLike<T>,

source§

fn contains_all_of_in_order<OSA, OS>(&self, expected: OSA) -> R
where T: PartialOrd + Eq + Debug, OS: OrderedSetLike<T>, OSA: Borrow<OS>,

Checks that the subject contains at least all elements of expected in the same order. Read more
source§

fn contains_exactly_in_order<OSA, OS>(&self, expected: OSA) -> R
where T: PartialOrd + Eq + Debug, OS: OrderedSetLike<T>, OSA: Borrow<OS>,

Checks that the subject exactly contains elements of expected in the same order. Read more
source§

impl<R, OK: Debug, ERR: Debug> ResultAssertion<R, OK, ERR> for Subject<'_, Result<OK, ERR>, (), R>

source§

fn is_ok(&self) -> R

Checks that the subject is Result::Ok(_).
source§

fn is_err(&self) -> R

Checks that the subject is Result::Err(_).
source§

fn has_ok<B: Borrow<OK>>(&self, expected: B) -> R
where OK: PartialEq,

Checks that the subject is Result::Ok(expected).
source§

fn has_err<B: Borrow<ERR>>(&self, expected: B) -> R
where ERR: PartialEq,

Checks that the subject is Result::Err(expected).
source§

fn ok(&self) -> Subject<'_, OK, (), R>

Returns a new subject which is the ok value of the subject if the subject has ok value. Otherwise, it fails.
source§

fn err(&self) -> Subject<'_, ERR, (), R>

Returns a new subject which is the error value of the subject if the subject has error value. Otherwise, it fails.
source§

impl<'a, T, R, ST> SetAssertion<'a, ST, T, R> for Subject<'a, ST, (), R>
where AssertionResult: AssertionStrategy<R>, T: Eq + Debug, ST: SetLike<T>,

source§

fn has_length(&self, length: usize) -> R

Checks that the subject has the given length.
source§

fn is_empty(&self) -> R
where T: Debug,

Checks that the subject is empty.
source§

fn contains<B: Borrow<T>>(&self, expected: B) -> R
where T: PartialEq + Eq + Debug + Hash,

Checks that the subject has expected.
source§

fn does_not_contain<B>(&self, element: B) -> R
where B: Borrow<T>, T: PartialEq + Debug,

Checks that the subject does not contain element.
source§

fn does_not_contain_any<B: Borrow<Vec<T>>>(&self, elements: B) -> R
where T: PartialEq + Debug,

Checks that the subject does not contain any element of elements.
source§

impl<R> StringAssertion<R> for Subject<'_, &str, (), R>

source§

fn is_same_string_to<E: Into<String>>(&self, expected: E) -> R

Checks that the subject is same string to expected.
source§

fn contains<E: Into<String>>(&self, expected: E) -> R

Checks that the subject contains expected.
source§

fn does_not_contain<E: Into<String>>(&self, value: E) -> R

Checks that the subject does not contains value.
source§

fn starts_with<E: Into<String>>(&self, expected: E) -> R

Checks that the subject starts with expected.
source§

fn ends_with<E: Into<String>>(&self, expected: E) -> R

Checks that the subject ends with expected.
source§

impl<R> StringAssertion<R> for Subject<'_, String, (), R>

source§

fn is_same_string_to<E: Into<String>>(&self, expected: E) -> R

Checks that the subject is same string to expected.
source§

fn contains<E: Into<String>>(&self, expected: E) -> R

Checks that the subject contains expected.
source§

fn does_not_contain<E: Into<String>>(&self, value: E) -> R

Checks that the subject does not contains value.
source§

fn starts_with<E: Into<String>>(&self, expected: E) -> R

Checks that the subject starts with expected.
source§

fn ends_with<E: Into<String>>(&self, expected: E) -> R

Checks that the subject ends with expected.
source§

impl<'a, T, R> VecAssertion<'a, Vec<T>, T, R> for Subject<'a, Vec<T>, (), R>

source§

fn contains<B>(&self, element: B) -> R
where B: Borrow<T>, T: PartialEq + Debug,

Checks that the subject contains the element expected. Read more
source§

fn does_not_contain<B>(&self, element: B) -> R
where B: Borrow<T>, T: PartialEq + Debug,

Checks that the subject does not contains the element. Read more
source§

fn contains_exactly<B: Borrow<Vec<T>>>(self, expected_iter: B) -> R
where T: PartialEq + Debug,

Checks that the subject exactly contains elements of expected_vec. Read more
source§

fn contains_exactly_in_order<B: Borrow<Vec<T>>>(self, expected_iter: B) -> R
where T: PartialEq + Debug,

Checks that the subject exactly contains expected_vec in the same order. Read more
source§

fn does_not_contain_any<B: Borrow<Vec<T>>>(&self, elements: B) -> R
where T: PartialEq + Debug,

Checks that the subject does not contain any element of elements. Read more
source§

fn is_empty(&self) -> R
where T: Debug,

Checks that the subject is empty. Read more
source§

fn is_not_empty(&self) -> R
where T: Debug,

Checks that the subject is not empty. Read more
source§

fn has_length(&self, length: usize) -> R

Checks that the subject is the given length. Read more

Auto Trait Implementations§

§

impl<'a, Sub, Opt, Ret> Freeze for Subject<'a, Sub, Opt, Ret>
where Opt: Freeze, Sub: Freeze,

§

impl<'a, Sub, Opt, Ret> RefUnwindSafe for Subject<'a, Sub, Opt, Ret>
where Opt: RefUnwindSafe, Sub: RefUnwindSafe, Ret: RefUnwindSafe,

§

impl<'a, Sub, Opt, Ret> Send for Subject<'a, Sub, Opt, Ret>
where Opt: Send, Sub: Send + Sync, Ret: Send,

§

impl<'a, Sub, Opt, Ret> Sync for Subject<'a, Sub, Opt, Ret>
where Opt: Sync, Sub: Sync, Ret: Sync,

§

impl<'a, Sub, Opt, Ret> Unpin for Subject<'a, Sub, Opt, Ret>
where Opt: Unpin, Sub: Unpin, Ret: Unpin,

§

impl<'a, Sub, Opt, Ret> UnwindSafe for Subject<'a, Sub, Opt, Ret>
where Opt: UnwindSafe, Sub: UnwindSafe + RefUnwindSafe, Ret: UnwindSafe,

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<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<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, 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.