ActionAssertions

Trait ActionAssertions 

Source
pub trait ActionAssertions<A> {
    // Required methods
    fn assert_empty(&self);
    fn assert_not_empty(&self);
    fn assert_count(&self, n: usize);
    fn assert_first_matches<F: Fn(&A) -> bool>(&self, f: F);
    fn assert_any_matches<F: Fn(&A) -> bool>(&self, f: F);
    fn assert_all_match<F: Fn(&A) -> bool>(&self, f: F);
    fn assert_none_match<F: Fn(&A) -> bool>(&self, f: F);
}
Expand description

Fluent assertion trait for action vectors.

This trait only requires Debug, making it usable with any action type. For equality-based assertions (like assert_first), use ActionAssertionsEq.

§Example

use tui_dispatch::testing::ActionAssertions;

let actions = harness.drain_emitted();
actions.assert_not_empty();
actions.assert_count(3);
actions.assert_any_matches(|a| matches!(a, Action::SelectKey(i) if *i > 0));

Required Methods§

Source

fn assert_empty(&self)

Assert that the vector is empty.

§Panics

Panics if the vector is not empty.

Source

fn assert_not_empty(&self)

Assert that the vector is not empty.

§Panics

Panics if the vector is empty.

Source

fn assert_count(&self, n: usize)

Assert that the vector has exactly n elements.

§Panics

Panics if the count doesn’t match.

Source

fn assert_first_matches<F: Fn(&A) -> bool>(&self, f: F)

Assert that the first action matches a predicate.

§Panics

Panics if the vector is empty or the predicate returns false.

Source

fn assert_any_matches<F: Fn(&A) -> bool>(&self, f: F)

Assert that any action matches a predicate.

§Panics

Panics if no action matches the predicate.

Source

fn assert_all_match<F: Fn(&A) -> bool>(&self, f: F)

Assert that all actions match a predicate.

§Panics

Panics if any action doesn’t match the predicate.

Source

fn assert_none_match<F: Fn(&A) -> bool>(&self, f: F)

Assert that no action matches a predicate.

§Panics

Panics if any action matches the predicate.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<A: Debug> ActionAssertions<A> for [A]

Source§

fn assert_empty(&self)

Source§

fn assert_not_empty(&self)

Source§

fn assert_count(&self, n: usize)

Source§

fn assert_first_matches<F: Fn(&A) -> bool>(&self, f: F)

Source§

fn assert_any_matches<F: Fn(&A) -> bool>(&self, f: F)

Source§

fn assert_all_match<F: Fn(&A) -> bool>(&self, f: F)

Source§

fn assert_none_match<F: Fn(&A) -> bool>(&self, f: F)

Source§

impl<A: Debug> ActionAssertions<A> for Vec<A>

Source§

fn assert_empty(&self)

Source§

fn assert_not_empty(&self)

Source§

fn assert_count(&self, n: usize)

Source§

fn assert_first_matches<F: Fn(&A) -> bool>(&self, f: F)

Source§

fn assert_any_matches<F: Fn(&A) -> bool>(&self, f: F)

Source§

fn assert_all_match<F: Fn(&A) -> bool>(&self, f: F)

Source§

fn assert_none_match<F: Fn(&A) -> bool>(&self, f: F)

Implementors§