Skip to content

Conversation

yatsenko-ihor
Copy link

Changed signature of method containsInAnyOrder to allow avoid calling toArray() method or casting to the array and build next construction

List actual = Arrays.asList("a", "b", "c");
List expected = Arrays.asList("a", "c");
assertThat(list, containsInAnyOrder(expected))

Some results from the internet with recommendations to call toArray():
https://stackoverflow.com/questions/21624592/hamcrest-compare-collections
http://haroonzone.github.io/comparing-lists-with-hamcrest/ (ListMatcher2.java)

… toArray() method or casting to array and build next construction

List<String> actual = Arrays.asList("a", "b", "c");
List<String> expected = Arrays.asList("a", "c");
assertThat(list, containsInAnyOrder(expected))

Some results from internet with reccomendations to call toArray():
https://stackoverflow.com/questions/21624592/hamcrest-compare-collections
http://haroonzone.github.io/comparing-lists-with-hamcrest/ (ListMatcher2.java)
@tumbarumba
Copy link
Member

I really like they way that this simplifies the calling code for collections of items.

Without knowing if this is true, I also worry that this will break other code that is passing collections of matchers. Can you add another test to IsIterableContainingInAnyOrderTest to verify that this doesn't cause a regression?

@nhojpatrick
Copy link
Member

@yatsenko-ihor looking at closing pr and getting merged, looks a good idea

can you keep the current signature but mark as deprecated as i'm sure if we do this change we might get bugs as a result if people are using existing signature

please can you rebase from master, as hamcrest-core and hamcrest-library have been refactored a lot and also deprecated, so that everything is just in hamcrest.

@nhojpatrick
Copy link
Member

Going to try and kick start hamcrest, so if you want to get it merged, please rebase from the branch v2.3-candidates.
Still trying to understand how has permissions to perform a release.

@nhojpatrick nhojpatrick force-pushed the master branch 2 times, most recently from 9bc653b to e9f7fc8 Compare February 13, 2022 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Needs triage
Development

Successfully merging this pull request may close these issues.

3 participants