JavaHamcrest icon indicating copy to clipboard operation
JavaHamcrest copied to clipboard

issue with containg

Open sarahBuisson opened this issue 8 years ago • 2 comments

the line assertThat(Arrays.asList(1,1), org.hamcrest.Matchers.contains(1));

fail.

sarahBuisson avatar Nov 05 '17 19:11 sarahBuisson

This is the intended behaviour. contains only matches if all parameters have a one-to-one correspondence to the list elements. So this would work:

assertThat(Arrays.asList(1,1), org.hamcrest.Matchers.contains(1, 1));

To check if the list has at least one element use

assertThat(Arrays.asList(1,1), org.hamcrest.Matchers.hasItem(1));

BlueIce avatar Nov 08 '17 18:11 BlueIce

#140 ;)

hakanai avatar Feb 08 '18 04:02 hakanai