Function googletest::matchers::len
source · pub fn len<T: Debug + ?Sized, E: Matcher<ActualT = usize>>(
expected: E
) -> impl Matcher<ActualT = T>where
for<'a> &'a T: IntoIterator,
Expand description
Matches a container whose number of elements matches expected
.
This matches against a container over which one can iterate. This includes
the standard Rust containers, arrays, and (when dereferenced) slices. More
precisely, a shared borrow of the actual type must implement
IntoIterator
.
let array = [1,2,3];
verify_that!(array, len(eq(3)))?;
let vec = vec![1,2,3];
verify_that!(vec, len(eq(3)))?;
let slice = vec.as_slice();
verify_that!(*slice, len(eq(3)))?;
The parameter expected
can be any integer numeric matcher.
let vec = vec![1,2,3];
verify_that!(vec, len(gt(1)))?;