/** * Creates a matcher for {@link Iterable}s that matches when a single pass over the * examined {@link Iterable} yields a series of items, each logically equal to the * corresponding item in the specified items. For a positive match, the examined iterable * must be of the same length as the number of specified items. * For example: * <pre>assertThat(Arrays.asList("foo", "bar"), contains("foo", "bar"))</pre> * * @param items * the items that must equal the items provided by an examined {@link Iterable} */ @SafeVarargs public static <E> Matcher<Iterable<? extends E>> contains(E... items) { return contains(asEqualMatchers(items)); }
/** * Creates a matcher for arrays that matches when each item in the examined array is * logically equal to the corresponding item in the specified items. For a positive match, * the examined array must be of the same length as the number of specified items. * For example: * <pre>assertThat(new String[]{"foo", "bar"}, contains("foo", "bar"))</pre> * * @param items * the items that must equal the items within an examined array */ @SafeVarargs public static <E> Matcher<E[]> arrayContaining(E... items) { return arrayContaining(asEqualMatchers(items)); } /**
/** * <p>Creates an order agnostic matcher for arrays that matches when each item in the * examined array is logically equal to one item anywhere in the specified items. * For a positive match, the examined array must be of the same length as the number of * specified items. * </p> * <p>N.B. each of the specified items will only be used once during a given examination, so be * careful when specifying items that may be equal to more than one entry in an examined * array. * </p> * <p> * For example: * </p> * <pre>assertThat(new String[]{"foo", "bar"}, containsInAnyOrder("bar", "foo"))</pre> * * @param items * the items that must equal the entries of an examined array, in any order */ @SafeVarargs public static <E> Matcher<E[]> arrayContainingInAnyOrder(E... items) { return arrayContainingInAnyOrder(asEqualMatchers(items)); }
/** * Creates a matcher for {@link Iterable}s that matches when a single pass over the * examined {@link Iterable} yields a series of items, each logically equal to the * corresponding item in the specified items. For a positive match, the examined iterable * must be of the same length as the number of specified items. * For example: * <pre>assertThat(Arrays.asList("foo", "bar"), contains("foo", "bar"))</pre> * * @param items * the items that must equal the items provided by an examined {@link Iterable} */ @SafeVarargs public static <E> Matcher<Iterable<? extends E>> contains(E... items) { return contains(asEqualMatchers(items)); }
/** * Creates a matcher for arrays that matches when each item in the examined array is * logically equal to the corresponding item in the specified items. For a positive match, * the examined array must be of the same length as the number of specified items. * For example: * <pre>assertThat(new String[]{"foo", "bar"}, contains("foo", "bar"))</pre> * * @param items * the items that must equal the items within an examined array */ @SafeVarargs public static <E> Matcher<E[]> arrayContaining(E... items) { return arrayContaining(asEqualMatchers(items)); } /**
/** * <p>Creates an order agnostic matcher for arrays that matches when each item in the * examined array is logically equal to one item anywhere in the specified items. * For a positive match, the examined array must be of the same length as the number of * specified items. * </p> * <p>N.B. each of the specified items will only be used once during a given examination, so be * careful when specifying items that may be equal to more than one entry in an examined * array. * </p> * <p> * For example: * </p> * <pre>assertThat(new String[]{"foo", "bar"}, containsInAnyOrder("bar", "foo"))</pre> * * @param items * the items that must equal the entries of an examined array, in any order */ @SafeVarargs public static <E> Matcher<E[]> arrayContainingInAnyOrder(E... items) { return arrayContainingInAnyOrder(asEqualMatchers(items)); }