pub trait AssertIteratorContainsInAnyOrder<'a, S, E, R> {
// Required methods
fn contains_exactly_in_any_order(self, expected: E) -> Spec<'a, S, R>;
fn contains_any_of(self, expected: E) -> Spec<'a, S, R>;
fn does_not_contain_any_of(self, expected: E) -> Spec<'a, S, R>;
fn contains_all_of(self, expected: E) -> Spec<'a, S, R>;
fn contains_only(self, expected: E) -> Spec<'a, S, R>;
fn contains_only_once(self, expected: E) -> Spec<'a, S, R>;
}Expand description
Assert values in a collection.
These assertions do not rely on the order in which the collection iterates
over its values. They are implemented for any iterator over items that
implement PartialEq<E> with E being the type of the items in the
expected collection or iterator.
Required Methods§
Sourcefn contains_exactly_in_any_order(self, expected: E) -> Spec<'a, S, R>
fn contains_exactly_in_any_order(self, expected: E) -> Spec<'a, S, R>
Verifies that the actual collection/iterator contains exactly the given values and nothing else in any order.
§Examples
use asserting::prelude::*;
use std::collections::BTreeMap;
let some_array = [1, 3, 5, 7];
assert_that!(some_array).contains_exactly_in_any_order([3, 1, 5, 7]);
let some_slice = &['b', 'X', 'k', 'G'][..];
assert_that!(some_slice).contains_exactly_in_any_order(&['X', 'k', 'b', 'G']);
let some_vec = vec![12, 4, 6, 10, 8];
assert_that!(some_vec).contains_exactly_in_any_order([8, 10, 6, 4, 12]);
let some_btree_map = BTreeMap::from_iter([('a', 3), ('b', 0), ('c', 8)]);
assert_that!(some_btree_map).contains_exactly_in_any_order([('b', 0), ('a', 3), ('c', 8)]);Sourcefn contains_any_of(self, expected: E) -> Spec<'a, S, R>
fn contains_any_of(self, expected: E) -> Spec<'a, S, R>
Verifies that the actual collection/iterator contains at least one of the specified values.
§Examples
use asserting::prelude::*;
use std::collections::BTreeMap;
let some_array = [1, 3, 5, 7];
assert_that!(some_array).contains_any_of([2, 3, 4]);
let some_slice = &['b', 'X', 'k', 'G'][..];
assert_that!(some_slice).contains_any_of(&['a', 'b', 'c', 'd']);
let some_vec = vec![12, 4, 6, 10, 8];
assert_that!(some_vec).contains_any_of([1, 2, 3, 4, 5]);
let some_btree_map = BTreeMap::from_iter([('a', 3), ('b', 0), ('c', 8)]);
assert_that!(some_btree_map).contains_any_of([('x', 2), ('a', 3), ('y', 7)]);Sourcefn does_not_contain_any_of(self, expected: E) -> Spec<'a, S, R>
fn does_not_contain_any_of(self, expected: E) -> Spec<'a, S, R>
Verifies that the actual collection/iterator does not contain any of the specified values.
§Examples
use asserting::prelude::*;
use std::collections::BTreeMap;
let some_array = [1, 3, 5, 7];
assert_that!(some_array).does_not_contain_any_of([2, 4, 6]);
let some_slice = &['b', 'X', 'k', 'G'][..];
assert_that!(some_slice).does_not_contain_any_of(&['a', 'A', 'c', 'd']);
let some_vec = vec![12, 4, 6, 10, 8];
assert_that!(some_vec).does_not_contain_any_of([1, 2, 3, 5, 7]);
let some_btree_map = BTreeMap::from_iter([('a', 3), ('b', 0), ('c', 8)]);
assert_that!(some_btree_map).does_not_contain_any_of([('x', 2), ('z', 3), ('y', 7)]);Sourcefn contains_all_of(self, expected: E) -> Spec<'a, S, R>
fn contains_all_of(self, expected: E) -> Spec<'a, S, R>
Verifies that the actual collection/iterator contains the given values in any order.
The collection/iterator may contain more values than the given ones, but at least all the specified ones.
§Examples
use asserting::prelude::*;
use std::collections::BTreeMap;
let some_array = [1, 3, 5, 7];
assert_that!(some_array).contains_all_of([3, 1, 5]);
let some_slice = &['b', 'X', 'k', 'G'][..];
assert_that!(some_slice).contains_all_of(&['k', 'b']);
let some_vec = vec![12, 4, 6, 10, 8];
assert_that!(some_vec).contains_all_of([4, 6, 10, 12]);
let some_btree_map = BTreeMap::from_iter([('a', 3), ('b', 0), ('c', 8)]);
assert_that!(some_btree_map).contains_all_of([('a', 3), ('b', 0)]);Sourcefn contains_only(self, expected: E) -> Spec<'a, S, R>
fn contains_only(self, expected: E) -> Spec<'a, S, R>
Verifies that the actual collection/iterator contains only the given values and nothing else in any order and ignoring duplicates.
The collection may contain fewer values than the expected ones.
§Examples
use asserting::prelude::*;
use std::collections::BTreeMap;
let some_array = [1, 3, 5, 7];
assert_that!(some_array).contains_only([0, 5, 3, 1, 7, 9]);
let some_slice = &['b', 'X', 'k', 'G'][..];
assert_that!(some_slice).contains_only(&['X', 'a', 'k', 'b', 'G', 'A']);
let some_vec = vec![12, 4, 6, 10, 8];
assert_that!(some_vec).contains_only([2, 4, 6, 8, 10, 12, 14, 0]);
let some_btree_map = BTreeMap::from_iter([('a', 3), ('b', 0), ('c', 8)]);
assert_that!(some_btree_map).contains_only([('a', 3), ('b', 0), ('c', 8), ('d', 4)]);Sourcefn contains_only_once(self, expected: E) -> Spec<'a, S, R>
fn contains_only_once(self, expected: E) -> Spec<'a, S, R>
Verifies that the actual collection/iterator contains only the given values in any order and each of them only once.
The collection may contain fewer values than the expected ones.
§Examples
use asserting::prelude::*;
use std::collections::BTreeMap;
let some_array = [1, 3, 5, 7];
assert_that!(some_array).contains_only_once([0, 1, 3, 5, 7, 9]);
let some_slice = &['b', 'X', 'k', 'G'][..];
assert_that!(some_slice).contains_only_once(&['a', 'b', 'X', 'k', 'G']);
let some_vec = vec![12, 4, 6, 10, 8];
assert_that!(some_vec).contains_only_once([4, 6, 8, 10, 12, 15, 20]);