pub trait MapAssertion<'a, K: 'a + Eq, V, ML, R>where
AssertionResult: AssertionStrategy<R>,
ML: MapLike<K, V>,{
// Required methods
fn has_length(&self, length: usize) -> R;
fn is_empty(&self) -> R
where K: Debug;
fn is_not_empty(&self) -> R
where K: Debug;
fn contains_key<BK>(&self, key: BK) -> R
where BK: Borrow<K>,
K: Eq + Hash + Debug;
fn does_not_contain_key<BK>(&self, key: BK) -> R
where BK: Borrow<K>,
K: Eq + Hash + Debug;
fn contains_entry<BK, BV>(&self, key: BK, value: BV) -> R
where BK: Borrow<K>,
BV: Borrow<V>,
K: Eq + Hash + Debug,
V: Eq + Debug;
fn does_not_contain_entry<BK, BV>(&self, key: BK, value: BV) -> R
where BK: Borrow<K>,
BV: Borrow<V>,
K: Eq + Hash + Debug,
V: Eq + Debug;
fn contains_at_least<BM, OML>(&self, expected: BM) -> R
where K: Eq + Hash + Debug,
V: Eq + Debug,
OML: MapLike<K, V> + 'a,
BM: Borrow<OML> + 'a;
fn does_not_contain_any<BM, OML>(&self, expected: BM) -> R
where K: Eq + Hash + Debug,
V: Eq + Debug,
OML: MapLike<K, V> + 'a,
BM: Borrow<OML> + 'a;
fn contains_exactly<BM, OML>(&self, expected: BM) -> R
where K: Eq + Hash + Debug,
V: Eq + Debug,
OML: MapLike<K, V> + 'a,
BM: Borrow<OML> + 'a;
fn key_set<'b>(&'b self) -> Subject<'_, ML::It<'b>, (), R>
where K: 'b;
}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§
Sourcefn has_length(&self, length: usize) -> R
fn has_length(&self, length: usize) -> R
Checks that the subject has the given length.
Sourcefn is_not_empty(&self) -> Rwhere
K: Debug,
fn is_not_empty(&self) -> Rwhere
K: Debug,
Checks that the subject is not empty.
Sourcefn contains_key<BK>(&self, key: BK) -> R
fn contains_key<BK>(&self, key: BK) -> R
Checks that the subject has the given key.
Sourcefn does_not_contain_key<BK>(&self, key: BK) -> R
fn does_not_contain_key<BK>(&self, key: BK) -> R
Checks that the subject does not have the given key.
Sourcefn contains_entry<BK, BV>(&self, key: BK, value: BV) -> R
fn contains_entry<BK, BV>(&self, key: BK, value: BV) -> R
Checks that the subject has entry with the given key and value.
Sourcefn does_not_contain_entry<BK, BV>(&self, key: BK, value: BV) -> R
fn does_not_contain_entry<BK, BV>(&self, key: BK, value: BV) -> R
Checks that the subject does not contain entry with the given key and value.
Sourcefn contains_at_least<BM, OML>(&self, expected: BM) -> R
fn contains_at_least<BM, OML>(&self, expected: BM) -> R
Checks that the subject contains all entries from expected.
Sourcefn does_not_contain_any<BM, OML>(&self, expected: BM) -> R
fn does_not_contain_any<BM, OML>(&self, expected: BM) -> R
Checks that the subject does not contain any entries from expected.
Sourcefn contains_exactly<BM, OML>(&self, expected: BM) -> R
fn contains_exactly<BM, OML>(&self, expected: BM) -> R
Checks that the subject contains only entries from expected.
Sourcefn key_set<'b>(&'b self) -> Subject<'_, ML::It<'b>, (), R>where
K: 'b,
fn key_set<'b>(&'b self) -> Subject<'_, ML::It<'b>, (), R>where
K: 'b,
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());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.