Struct exonum_testkit::compare::Comparison
[−]
[src]
pub struct Comparison<T> { /* fields omitted */ }
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
impl<T: Debug> Debug for Comparison<T>
[src]
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,