pub trait SetAssertion<'a, S, T, R> {
    // Required methods
    fn has_length(&self, length: usize) -> R;
    fn is_empty(&self) -> R
       where T: Debug;
    fn contains<B: Borrow<T>>(&self, expected: B) -> R
       where T: PartialEq + Eq + Debug + Hash;
    fn does_not_contain<B>(&self, element: B) -> R
       where B: Borrow<T>,
             T: PartialEq + Debug;
    fn does_not_contain_any<B: Borrow<Vec<T>>>(&self, elements: B) -> R
       where T: PartialEq + Debug;
}
Expand description

Trait for set assertion.

Example

use assertor::*;
use std::collections::HashSet;

let mut set = HashSet::new();
assert_that!(set).is_empty();

set.insert("a");
set.insert("b");
set.insert("c");

assert_that!(set).contains("a");
assert_that!(set).has_length(3);
use assertor::*;
use std::collections::HashSet;

let mut set = HashSet::new();
set.insert("a");
assert_that!(set).contains("z");
// expected to contain  : "z"
// but did not
// though it did contain: ["a"]

Required Methods§

source

fn has_length(&self, length: usize) -> R

Checks that the subject has the given length.

source

fn is_empty(&self) -> Rwhere T: Debug,

Checks that the subject is empty.

source

fn contains<B: Borrow<T>>(&self, expected: B) -> Rwhere T: PartialEq + Eq + Debug + Hash,

Checks that the subject has expected.

source

fn does_not_contain<B>(&self, element: B) -> Rwhere B: Borrow<T>, T: PartialEq + Debug,

Checks that the subject does not contain element.

source

fn does_not_contain_any<B: Borrow<Vec<T>>>(&self, elements: B) -> Rwhere T: PartialEq + Debug,

Checks that the subject does not contain any element of elements.

Implementors§

source§

impl<'a, T, R> SetAssertion<'a, HashSet<T, RandomState>, T, R> for Subject<'a, HashSet<T>, (), R>where AssertionResult: AssertionStrategy<R>,