pub struct Assertion;Expand description
Assertion helpers for testing
Implementations§
Source§impl Assertion
impl Assertion
Sourcepub fn equals<T: PartialEq + Debug>(expected: &T, actual: &T) -> AssertionResult
pub fn equals<T: PartialEq + Debug>(expected: &T, actual: &T) -> AssertionResult
Assert two values are equal
Sourcepub fn contains(haystack: &str, needle: &str) -> AssertionResult
pub fn contains(haystack: &str, needle: &str) -> AssertionResult
Assert a string contains a substring
Sourcepub fn in_range(value: f64, min: f64, max: f64) -> AssertionResult
pub fn in_range(value: f64, min: f64, max: f64) -> AssertionResult
Assert a value is in a range
Sourcepub fn is_true(condition: bool, message: &str) -> AssertionResult
pub fn is_true(condition: bool, message: &str) -> AssertionResult
Assert a condition is true
Sourcepub fn is_false(condition: bool, message: &str) -> AssertionResult
pub fn is_false(condition: bool, message: &str) -> AssertionResult
Assert a condition is false
Sourcepub fn is_some<T>(opt: &Option<T>) -> AssertionResult
pub fn is_some<T>(opt: &Option<T>) -> AssertionResult
Assert an Option is Some
Sourcepub fn is_none<T>(opt: &Option<T>) -> AssertionResult
pub fn is_none<T>(opt: &Option<T>) -> AssertionResult
Assert an Option is None
Sourcepub fn is_ok<T, E>(result: &Result<T, E>) -> AssertionResult
pub fn is_ok<T, E>(result: &Result<T, E>) -> AssertionResult
Assert a Result is Ok
Sourcepub fn is_err<T, E>(result: &Result<T, E>) -> AssertionResult
pub fn is_err<T, E>(result: &Result<T, E>) -> AssertionResult
Assert a Result is Err
Sourcepub fn approx_eq(a: f64, b: f64, epsilon: f64) -> AssertionResult
pub fn approx_eq(a: f64, b: f64, epsilon: f64) -> AssertionResult
Assert two floats are approximately equal
Sourcepub fn has_length<T>(collection: &[T], expected: usize) -> AssertionResult
pub fn has_length<T>(collection: &[T], expected: usize) -> AssertionResult
Assert a collection has expected length
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Assertion
impl RefUnwindSafe for Assertion
impl Send for Assertion
impl Sync for Assertion
impl Unpin for Assertion
impl UnsafeUnpin for Assertion
impl UnwindSafe for Assertion
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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