galvanic_assert::matchers::collection

Function contains_in_any_order

Source
pub fn contains_in_any_order<'a, T, I, J>(
    expected_elements: I,
) -> Box<dyn Matcher<'a, J> + 'a>
where T: PartialEq + Debug + 'a, I: IntoIterator<Item = T> + 'a, J: IntoIterator<Item = T> + 'a, ContainsInAnyOrder<T>: Matcher<'a, J>,
Expand description

Matches if the asserted collection contains all and only of the expected elements in any order.

#Examples

use galvanic_assert::matchers::collection::*;
assert_that!(&vec![1,2,3,4,5,6], contains_in_any_order(vec![2,4,1,5,3,6]));
assert_that!(
    // 6 is missing
    assert_that!(&vec![1,2,3,4,5,6], contains_in_any_order(vec![2,4,1,5,3])),
    panics
);
assert_that!(
    // 7 is added
    assert_that!(&vec![1,2,3,4,5,6], contains_in_any_order(vec![2,4,1,5,3,6,7])),
    panics
);