Struct Assertion

Source
pub struct Assertion<T> { /* private fields */ }

Implementations§

Source§

impl Assertion<bool>

Specific assertions for booleans

Source

pub fn be_true(self) -> Self

Asserts that the value is true

Source

pub fn be_false(self) -> Self

Asserts that the value is false

Source§

impl<E: Error> Assertion<E>

Source

pub fn match_error<T: Error + Debug>(self, error: T) -> Self

Asserts that the error is equal to the given error

Source

pub fn contain_message(self, expected_message: &str) -> Self

Asserts that the error message contains the given message

Source§

impl<T> Assertion<T>
where T: PartialOrd + Display + Zero + Copy,

Specific assertions for numeric types

Source

pub fn be_greater_than_or_equal_to(&self, other: T) -> &Self

Asserts that the value is greater than or equal to the given value

Source

pub fn be_greater_than(&self, other: T) -> &Self

Asserts that the value is greater than the given value

Source

pub fn be_less_than_or_equal_to(&self, other: T) -> &Self

Asserts that the value is less than or equal to the given value

Source

pub fn be_less_than(&self, other: T) -> &Self

Asserts that the value is less than the given value

Source

pub fn be_positive(&self) -> &Self

Asserts that the value is positive

Source

pub fn be_negative(&self) -> &Self

Asserts that the value is negative

Source

pub fn be_in_range(&self, start: T, end: T) -> &Self

Asserts that the value is in the given range

Source

pub fn not_be_in_range(&self, start: T, end: T) -> &Self

Asserts that the value is not in the given range

Source§

impl<T: Debug + PartialEq> Assertion<Option<T>>

Source

pub fn be_some(&self) -> &Self

Asserts that the Option is Some

Source

pub fn contains(&self, expected: &T) -> &Self

Asserts that the Option is Some and contains the expected value

Source

pub fn be_none(&self) -> &Self

Asserts that the Option is None

Source§

impl<T, E> Assertion<Result<T, E>>
where T: Debug, E: Debug,

Specific assertions for Result types

Source

pub fn be_ok(self) -> Assertion<T>

Asserts that the Result is Ok

Source

pub fn be_err(self) -> Assertion<E>

Asserts that the Result is Err

Source§

impl<T: AsRef<str>> Assertion<T>

Specific assertions for strings

Source

pub fn be_empty(&self) -> &Self

Asserts that the string is empty

Source

pub fn not_be_empty(&self) -> &Self

Asserts that the string is not empty

Source

pub fn start_with(&self, prefix: &str) -> &Self

Asserts that the string starts with a given prefix

Source

pub fn end_with(&self, suffix: &str) -> &Self

Asserts that the string ends with a given suffix

Source

pub fn contain(&self, substring: &str) -> &Self

Asserts that the string contains a given substring

Source

pub fn have_length(&self, length: usize) -> &Self

Asserts that the string has a given length

Source§

impl<T> Assertion<T>
where T: PartialEq + Display,

General assertions for all types

Source

pub fn be(&self, other: T) -> &Self

Source

pub fn not_be(&self, other: T) -> &Self

Auto Trait Implementations§

§

impl<T> Freeze for Assertion<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Assertion<T>
where T: RefUnwindSafe,

§

impl<T> Send for Assertion<T>
where T: Send,

§

impl<T> Sync for Assertion<T>
where T: Sync,

§

impl<T> Unpin for Assertion<T>
where T: Unpin,

§

impl<T> UnwindSafe for Assertion<T>
where T: 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> Should for T

Source§

fn should(self) -> Assertion<T>

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.