Trait assertor::MapAssertion[][src]

pub trait MapAssertion<'a, K, V, R> where
    AssertionResult: AssertionStrategy<R>, 
{ fn has_length(&self, length: usize) -> R;
fn is_empty(&self) -> R
    where
        K: Debug
;
fn contains_key<BK>(&self, key: BK) -> R
    where
        BK: Borrow<K>,
        K: Eq + Hash + Debug
;
fn key_set(&self) -> Subject<'_, Keys<'_, K, V>, (), R>; }
Expand description

Trait for map assertion.

Example

use std::collections::HashMap;
use assertor::*;

let mut map = HashMap::new();
assert_that!(map).is_empty();

map.insert("one", 1);
map.insert("two", 2);
map.insert("three", 3);

assert_that!(map).has_length(3);
assert_that!(map).contains_key("one");
assert_that!(map).key_set().contains_exactly(vec!["three","two","one"].iter());

Required methods

Checks that the subject has the given length.

Checks that the subject is empty.

Checks that the subject has the given key.

Returns a new subject which is an key set of the subject and which implements crate::IteratorAssertion.

Example

use std::collections::HashMap;
use assertor::*;
use assertor::IteratorAssertion;

let mut map = HashMap::new();
map.insert("one", 1);
map.insert("two", 2);
map.insert("three", 3);

assert_that!(map).key_set().contains(&"one");
assert_that!(map).key_set().contains_exactly(vec!["three","two","one"].iter());
assert_that!(map).key_set().contains_all_of(vec!["one", "two"].iter());

Implementors