[−][src]Struct exonum_testkit::compare::Comparison
Facilitation of comparison between 2 states.
Methods
impl<T> Comparison<T>
[src]
pub fn new(old: T, new: T) -> Self
[src]
Creates a comparison between 2 states.
pub fn map<'a, F, U>(&'a self, f: F) -> Comparison<U> where
F: Fn(&'a T) -> U,
[src]
F: Fn(&'a T) -> U,
Maps this comparison to another type of objects.
Examples
let comparison = Comparison::new(vec![1, 2, 3], vec![4, 5]) .map(Vec::len); // Now, this is a comparison between `3` and `2`
pub fn assert_before<P>(&self, message: &str, predicate: P) -> &Self where
P: Fn(&T) -> bool,
[src]
P: Fn(&T) -> bool,
Asserts a statement about the older state in this comparison.
Panics
- Panics if the statement does not hold.
Examples
Comparison::new(vec![1, 2, 3], vec![4, 5]) .map(Vec::len) .assert_before("Array length <= 5", |&len| len <= 5);
pub fn assert_after<P>(&self, message: &str, predicate: P) -> &Self where
P: Fn(&T) -> bool,
[src]
P: Fn(&T) -> bool,
Asserts a statement about the newer state in this comparison.
Panics
- Panics if the statement does not hold.
Examples
Comparison::new(vec![1, 2, 3], vec![4, 5]) .assert_after("The second element is greater than first", |v| { v[1] > v[0] });
pub fn assert<P>(&self, message: &str, predicate: P) -> &Self where
P: Fn(&T, &T) -> bool,
[src]
P: Fn(&T, &T) -> bool,
Asserts a statement about the both states in this comparison.
Panics
- Panics if the statement does not hold.
Examples
Comparison::new(vec![1, 2, 3], vec![4, 5]) .map(Vec::len) .assert("Less elements after", |&old, &new| old > new);
pub fn assert_inv<P>(&self, message: &str, predicate: P) -> &Self where
P: Fn(&T) -> bool,
[src]
P: Fn(&T) -> bool,
impl<T: PartialEq + Debug> Comparison<T>
[src]
pub fn assert_eq(&self, message: &str) -> &Self
[src]
Asserts that the states are equal (by the PartialEq
definition).
Panics
- Panics if the states are not equal.
Examples
Comparison::new(vec![1, 2, 3], vec![4, 5, 6]) .map(Vec::len) .assert_eq("Array length doesn't change");
pub fn assert_ne(&self, message: &str) -> &Self
[src]
Trait Implementations
Auto Trait Implementations
impl<T> Send for Comparison<T> where
T: Send,
T: Send,
impl<T> Sync for Comparison<T> where
T: Sync,
T: Sync,
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Erased for T
impl<T> Same for T
type Output = T
Should always be Self