Skip to content

Allow contains to match an empty iterable - #448

Open
PHJ2000 wants to merge 1 commit into
hamcrest:masterfrom
PHJ2000:fix/contains-empty-iterable
Open

PHJ2000 wants to merge 1 commit into
hamcrest:masterfrom
PHJ2000:fix/contains-empty-iterable

Conversation

@PHJ2000

@PHJ2000 PHJ2000 commented Oct 13, 2026

Copy link
Copy Markdown

Fixes #435.

Remove the check that throws when no expected elements are supplied. The existing matching logic then accepts an empty iterable and reports an unexpected item for a non-empty iterable, consistent with containsInAnyOrder.

Tests cover empty item arrays, matcher arrays and matcher lists, along with the matcher description and mismatch output.

./gradlew clean build javadoc passes on Java 8 and 21, with 496 tests passing on each.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

contains matcher should also support empty set evaluation or alternatively we should have one that can

1 participant