Function easy_assert::expected_vec_with
source · [−]pub fn expected_vec_with<T>(
values: Vec<T>,
description_func: fn(_: &T) -> String
) -> Vec<Expected<T>>Expand description
Convert vec with values into vec of Expected wrappers. You should provide your own function to represent value as String.
Examples
Basic usage:
use easy_assert::expected_vec_with;
fn my_description(value: &i32) -> String {
format!("My own description for value {}", value)
}
let expected = expected_vec_with(vec![1, 2, 3], my_description);Test usage:
use easy_assert::{actual_vec_with, expected_vec_with};
use easy_assert::list_assertions::ListAssert;
fn my_description(value: &i32) -> String {
format!("My own description for value {}", value)
}
ListAssert::assert_that(actual_vec_with(vec![1, 2, 3], my_description))
.with_element_matcher(|a, b| a.eq(b))
.is_equal_to(expected_vec_with(vec![3, 2, 1], my_description))
.in_any_order()