mr-sun / hamcrest

Hamcrest matchers for c++ (using with carnamock)
0 stars 0 forks source link

Matchers.contains does not always work for lists #210

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I am linking with hamcrest-all-1.3.jar.

The example given for

org.hamcrest.Matcher<java.lang.Iterable<? extends E>> 
contains(org.hamcrest.Matcher<? super E> itemMatcher)

is 

assertThat(Arrays.asList("foo"), contains(equalTo("foo")));

This works, but

assertThat(Arrays.asList("bar", "foo"), contains(equalTo("foo")));

fails! It only seems to try matching the first item in the list.

Original issue reported on code.google.com by immo.h.h...@gmail.com on 5 Aug 2014 at 7:28

GoogleCodeExporter commented 8 years ago
Isn't that the definition of contains()? If you didn't want the order to 
matter, isn't that containsInAnyOrder() instead?

Original comment by trejkaz on 4 Mar 2015 at 4:18