forked from skyscreamer/JSONassert
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request skyscreamer#111 from suraj1291993/master
Fixes for issue skyscreamer#105
- Loading branch information
Showing
4 changed files
with
80 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/test/java/org/skyscreamer/jsonassert/JSONArrayWithNullTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package org.skyscreamer.jsonassert; | ||
|
||
import org.json.JSONArray; | ||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
import org.junit.Test; | ||
|
||
public class JSONArrayWithNullTest { | ||
@Test | ||
public void testJSONArrayWithNullValue() throws JSONException { | ||
JSONArray jsonArray1 = getJSONArray1(); | ||
JSONArray jsonArray2 = getJSONArray2(); | ||
|
||
JSONAssert.assertEquals(jsonArray1, jsonArray2, true); | ||
JSONAssert.assertEquals(jsonArray1, jsonArray2, false); | ||
} | ||
|
||
@Test | ||
public void testJSONArrayWithNullValueAndJsonObject() throws JSONException { | ||
JSONArray jsonArray1 = getJSONArray1(); | ||
JSONObject jsonObject1 = new JSONObject(); | ||
jsonObject1.put("hey", "value"); | ||
|
||
JSONArray jsonArray2 = getJSONArray2(); | ||
JSONObject jsonObject2 = new JSONObject(); | ||
jsonObject2.put("hey", "value"); | ||
|
||
JSONAssert.assertEquals(jsonArray1, jsonArray2, true); | ||
JSONAssert.assertEquals(jsonArray1, jsonArray2, false); | ||
} | ||
|
||
private JSONArray getJSONArray1() { | ||
JSONArray jsonArray1 = new JSONArray(); | ||
jsonArray1.put(1); | ||
jsonArray1.put(null); | ||
jsonArray1.put(3); | ||
jsonArray1.put(2); | ||
return jsonArray1; | ||
} | ||
|
||
private JSONArray getJSONArray2() { | ||
JSONArray jsonArray1 = new JSONArray(); | ||
jsonArray1.put(1); | ||
jsonArray1.put(null); | ||
jsonArray1.put(3); | ||
jsonArray1.put(2); | ||
return jsonArray1; | ||
} | ||
} |