Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ private static class MatchSeries<F> {

public MatchSeries(List<Matcher<? super F>> matchers, Description mismatchDescription) {
this.mismatchDescription = mismatchDescription;
if (matchers.isEmpty()) {
throw new IllegalArgumentException("Should specify at least one expected element");
}
this.matchers = matchers;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.ArrayList;

import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
import static org.hamcrest.test.MatcherAssertions.*;
import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
Expand All @@ -24,6 +25,31 @@ protected Matcher<?> createMatcher() {
return contains(1, 2);
}

@Test
public void testMatchingEmptyIterableWithNoExpectedItems() {
assertMatches(contains(new String[0]), emptyList());
}

@Test
public void testMatchingEmptyIterableWithNoExpectedMatchers() {
assertMatches(contains(new Matcher<?>[0]), emptyList());
}

@Test
public void testMatchingEmptyIterableWithEmptyMatcherList() {
assertMatches(contains(emptyList()), emptyList());
}

@Test
public void testDoesNotMatchNonEmptyIterableWithNoExpectedItems() {
assertMismatchDescription("not matched: <1>", contains(new Integer[0]), singletonList(1));
}

@Test
public void testHasAReadableDescriptionWithNoExpectedItems() {
assertDescription("iterable containing []", contains(new Integer[0]));
}

@Test
public void testMatchingSingleItemIterable() throws Exception {
assertMatches("Single item iterable", contains(1), singletonList(1));
Expand Down