/** * Creates a matcher for {@link Iterable}s that matches when a single pass over the * examined {@link Iterable} yields an item count that is equal to the specified * <code>size</code> argument. * <p/> * For example: * <pre>assertThat(Arrays.asList("foo", "bar"), iterableWithSize(2))</pre> * * @param size * the number of items that should be yielded by an examined {@link Iterable} */ public static <E> org.hamcrest.Matcher<java.lang.Iterable<E>> iterableWithSize(int size) { return org.hamcrest.collection.IsIterableWithSize.<E>iterableWithSize(size); }
/** * Creates a matcher for {@link Iterable}s that matches when a single pass over the * examined {@link Iterable} yields an item count that satisfies the specified * matcher. * For example: * <pre>assertThat(Arrays.asList("foo", "bar"), iterableWithSize(equalTo(2)))</pre> * * @param sizeMatcher * a matcher for the number of items that should be yielded by an examined {@link Iterable} */ public static <E> Matcher<Iterable<E>> iterableWithSize(Matcher<? super Integer> sizeMatcher) { return new IsIterableWithSize<E>(sizeMatcher); }
/** * Creates a matcher for {@link Iterable}s that matches when a single pass over the * examined {@link Iterable} yields an item count that satisfies the specified * matcher. * <p/> * For example: * <pre>assertThat(Arrays.asList("foo", "bar"), iterableWithSize(equalTo(2)))</pre> * * @param sizeMatcher * a matcher for the number of items that should be yielded by an examined {@link Iterable} */ public static <E> org.hamcrest.Matcher<java.lang.Iterable<E>> iterableWithSize(org.hamcrest.Matcher<? super java.lang.Integer> sizeMatcher) { return org.hamcrest.collection.IsIterableWithSize.<E>iterableWithSize(sizeMatcher); }
/** * Creates a matcher for {@link Iterable}s that matches when a single pass over the * examined {@link Iterable} yields an item count that satisfies the specified * matcher. * <p/> * For example: * <pre>assertThat(Arrays.asList("foo", "bar"), iterableWithSize(equalTo(2)))</pre> * * @param sizeMatcher * a matcher for the number of items that should be yielded by an examined {@link Iterable} */ @Factory public static <E> Matcher<Iterable<E>> iterableWithSize(Matcher<? super Integer> sizeMatcher) { return new IsIterableWithSize<E>(sizeMatcher); }
/** * Creates a matcher for {@link Iterable}s that matches when a single pass over the * examined {@link Iterable} yields an item count that is equal to the specified * <code>size</code> argument. * For example: * <pre>assertThat(Arrays.asList("foo", "bar"), iterableWithSize(2))</pre> * * @param size * the number of items that should be yielded by an examined {@link Iterable} */ public static <E> org.hamcrest.Matcher<java.lang.Iterable<E>> iterableWithSize(int size) { return org.hamcrest.collection.IsIterableWithSize.iterableWithSize(size); }
/** * Creates a matcher for {@link Iterable}s that matches when a single pass over the * examined {@link Iterable} yields an item count that satisfies the specified * matcher. * For example: * <pre>assertThat(Arrays.asList("foo", "bar"), iterableWithSize(equalTo(2)))</pre> * * @param sizeMatcher * a matcher for the number of items that should be yielded by an examined {@link Iterable} */ public static <E> Matcher<Iterable<E>> iterableWithSize(Matcher<? super Integer> sizeMatcher) { return new IsIterableWithSize<E>(sizeMatcher); }
/** * Creates a matcher for {@link Iterable}s that matches when a single pass over the * examined {@link Iterable} yields an item count that satisfies the specified * matcher. * For example: * <pre>assertThat(Arrays.asList("foo", "bar"), iterableWithSize(equalTo(2)))</pre> * * @param sizeMatcher * a matcher for the number of items that should be yielded by an examined {@link Iterable} */ public static <E> org.hamcrest.Matcher<java.lang.Iterable<E>> iterableWithSize(org.hamcrest.Matcher<? super java.lang.Integer> sizeMatcher) { return org.hamcrest.collection.IsIterableWithSize.iterableWithSize(sizeMatcher); }
/** * Creates a matcher for {@link Iterable}s that matches when a single pass over the * examined {@link Iterable} yields an item count that satisfies the specified * matcher. * For example: * <pre>assertThat(Arrays.asList("foo", "bar"), iterableWithSize(equalTo(2)))</pre> * * @param sizeMatcher * a matcher for the number of items that should be yielded by an examined {@link Iterable} */ public static <E> Matcher<Iterable<E>> iterableWithSize(Matcher<? super Integer> sizeMatcher) { return new IsIterableWithSize<E>(sizeMatcher); }
/** * Creates a matcher for {@link Iterable}s that matches when a single pass over the * examined {@link Iterable} yields an item count that is equal to the specified * <code>size</code> argument. * <p/> * For example: * <pre>assertThat(Arrays.asList("foo", "bar"), iterableWithSize(2))</pre> * * @param size * the number of items that should be yielded by an examined {@link Iterable} */ @Factory public static <E> Matcher<Iterable<E>> iterableWithSize(int size) { return iterableWithSize(equalTo(size)); } }
/** * Creates a matcher for {@link Iterable}s that matches when a single pass over the * examined {@link Iterable} yields an item count that is equal to the specified * <code>size</code> argument. * For example: * <pre>assertThat(Arrays.asList("foo", "bar"), iterableWithSize(2))</pre> * * @param size * the number of items that should be yielded by an examined {@link Iterable} */ public static <E> Matcher<Iterable<E>> iterableWithSize(int size) { return iterableWithSize(equalTo(size)); } }
@Override protected Matcher<?> createMatcher() { return iterableWithSize(7); }
public void testHasAReadableDescription() { assertDescription("an iterable with size <4>", iterableWithSize(4)); } }
public void testMatchesEmptyIterable() throws Exception { assertMatches("Empty iterable", iterableWithSize(0), Collections.emptyList()); }
public void testMatchingSingleItemIterable() throws Exception { assertMatches("Single item iterable", iterableWithSize(1), Arrays.<Object>asList(1)); }
public void testMatchingMultipleItemIterable() throws Exception { assertMatches("Multiple item iterable", iterableWithSize(3), Arrays.<Object>asList(1, 2, 3)); }
public void testDoesNotMatchIncorrectSize() throws Exception { assertDoesNotMatch("Incorrect size", iterableWithSize(3), Arrays.<Object>asList(1)); }
/** * Creates a matcher for {@link Iterable}s that matches when a single pass over the * examined {@link Iterable} yields an item count that satisfies the specified * matcher. * For example: * <pre>assertThat(Arrays.asList("foo", "bar"), iterableWithSize(equalTo(2)))</pre> * * @param sizeMatcher * a matcher for the number of items that should be yielded by an examined {@link Iterable} */ public static <E> org.hamcrest.Matcher<java.lang.Iterable<E>> iterableWithSize(org.hamcrest.Matcher<? super java.lang.Integer> sizeMatcher) { return org.hamcrest.collection.IsIterableWithSize.<E>iterableWithSize(sizeMatcher); }
/** * Creates a matcher for {@link Iterable}s that matches when a single pass over the * examined {@link Iterable} yields an item count that is equal to the specified * <code>size</code> argument. * For example: * <pre>assertThat(Arrays.asList("foo", "bar"), iterableWithSize(2))</pre> * * @param size * the number of items that should be yielded by an examined {@link Iterable} */ public static <E> org.hamcrest.Matcher<java.lang.Iterable<E>> iterableWithSize(int size) { return org.hamcrest.collection.IsIterableWithSize.<E>iterableWithSize(size); }
/** * Creates a matcher for {@link Iterable}s that matches when a single pass over the * examined {@link Iterable} yields an item count that is equal to the specified * <code>size</code> argument. * For example: * <pre>assertThat(Arrays.asList("foo", "bar"), iterableWithSize(2))</pre> * * @param size * the number of items that should be yielded by an examined {@link Iterable} */ public static <E> Matcher<Iterable<E>> iterableWithSize(int size) { return iterableWithSize(equalTo(size)); } }
/** * Creates a matcher for {@link Iterable}s that matches when a single pass over the * examined {@link Iterable} yields an item count that satisfies the specified * matcher. * For example: * <pre>assertThat(Arrays.asList("foo", "bar"), iterableWithSize(equalTo(2)))</pre> * * @param sizeMatcher * a matcher for the number of items that should be yielded by an examined {@link Iterable} */ public static <E> org.hamcrest.Matcher<java.lang.Iterable<E>> iterableWithSize(org.hamcrest.Matcher<? super java.lang.Integer> sizeMatcher) { return org.hamcrest.collection.IsIterableWithSize.iterableWithSize(sizeMatcher); }