Struct exonum_testkit::compare::Comparison [] [src]

pub struct Comparison<T> { /* fields omitted */ }

Facilitation of comparison between 2 states.

Methods

impl<T> Comparison<T>
[src]

[src]

Creates a comparison between 2 states.

[src]

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`

[src]

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);

[src]

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]
    });

[src]

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);

[src]

Asserts a statement that should hold true for both states in this comparison.

Panics

  • Panics if the statement does not hold for either of states.

Examples

Comparison::new(vec![1, 2, 3], vec![4, 5])
    .map(Vec::len)
    .assert_inv("More than 1 element in array", |&len| len > 1);

impl<T: PartialEq + Debug> Comparison<T>
[src]

[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");

[src]

Asserts that the states are equal (by the PartialEq definition).

Panics

  • Panics if the states are equal.

Examples

Comparison::new(vec![1, 2, 3], vec![4, 5])
    .map(Vec::len)
    .assert_ne("Array length should change");

Trait Implementations

impl<T: Debug> Debug for Comparison<T>
[src]

[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<T> Send for Comparison<T> where
    T: Send

impl<T> Sync for Comparison<T> where
    T: Sync