Skip to content

Commit e94100b

Browse files
committed
added test for isequals with arrays containing null
1 parent 5623335 commit e94100b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

hamcrest-core/src/test/java/org/hamcrest/core/IsEqualTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,20 @@ public boolean equals(Object obj) {
7777
assertDoesNotMatch(matcher, null);
7878
}
7979

80+
@Test public void
81+
comparesTheElementsOfArraysWithNulls() {
82+
String[] s1 = {"a", null, "b"};
83+
String[] s2 = {"a", null, "b"};
84+
String[] s3 = {"c", "d"};
85+
String[] s4 = {"a", "b", "c", "d"};
86+
87+
final Matcher<String[]> matcher = equalTo(s1);
88+
assertMatches(matcher, s1);
89+
assertMatches(matcher, s2);
90+
assertDoesNotMatch(matcher, s3);
91+
assertDoesNotMatch(matcher, s4);
92+
}
93+
8094
@Test public void
8195
comparesTheElementsOfAnArrayOfPrimitiveTypes() {
8296
int[] i1 = new int[]{1, 2};

0 commit comments

Comments
 (0)