forked from skyscreamer/JSONassert
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJSONArrayWithNullTest.java
More file actions
49 lines (41 loc) · 1.43 KB
/
JSONArrayWithNullTest.java
File metadata and controls
49 lines (41 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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;
}
}