Skip to content

Commit c708261

Browse files
author
Carter Page
committed
Fixed JSONCompare handling for arrays of boolean
1 parent f5eb3d4 commit c708261

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/main/java/org/skyscreamer/jsonassert/JSONCompare.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ else if (allSimpleValues(expected)) {
148148
if (!actualCount.containsKey(o)) {
149149
result.missing(key + "[]", o);
150150
}
151-
else if (actualCount.get(o) != expectedCount.get(o)) {
151+
else if (!actualCount.get(o).equals(expectedCount.get(o))) {
152152
result.fail(key + "[]: Expected " + expectedCount.get(o) + " occurrence(s) of " + o
153153
+ " but got " + actualCount.get(o) + " occurrence(s)");
154154
}

src/test/java/org/skyscreamer/jsonassert/JSONAssertTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,13 @@ public void testFieldMismatch() throws JSONException {
155155
Assert.assertEquals("name", comparisonFailure.getField());
156156
}
157157

158+
@Test
159+
public void testBooleanArray() throws JSONException {
160+
testPass("[true, false, true, true, false]", "[true, false, true, true, false]", true);
161+
testPass("[false, true, true, false, true]", "[true, false, true, true, false]", false);
162+
testFail("[false, true, true, false, true]", "[true, false, true, true, false]", true);
163+
}
164+
158165
@Test
159166
public void testNullProperty() throws JSONException {
160167
testFail("{id:1,name:\"Joe\"}", "{id:1,name:null}", true);

0 commit comments

Comments
 (0)