|
6 | 6 |
|
7 | 7 | import static org.junit.Assert.assertEquals; |
8 | 8 | import static org.junit.Assert.assertFalse; |
| 9 | +import static org.junit.Assert.assertNotEquals; |
9 | 10 | import static org.junit.Assert.assertNotNull; |
10 | 11 | import static org.junit.Assert.assertNull; |
11 | 12 | import static org.junit.Assert.assertTrue; |
|
29 | 30 | import org.json.JSONException; |
30 | 31 | import org.json.JSONObject; |
31 | 32 | import org.json.JSONPointerException; |
| 33 | +import org.json.JSONString; |
32 | 34 | import org.json.JSONTokener; |
| 35 | +import org.json.junit.data.MyJsonString; |
33 | 36 | import org.junit.Test; |
34 | 37 |
|
35 | 38 | import com.jayway.jsonpath.Configuration; |
@@ -1334,4 +1337,25 @@ public void issue654StackOverflowInputWellFormed() { |
1334 | 1337 | fail("Excepected Exception."); |
1335 | 1338 | Util.checkJSONArrayMaps(json_input); |
1336 | 1339 | } |
| 1340 | + |
| 1341 | + @Test |
| 1342 | + public void testIssue682SimilarityOfJSONString() { |
| 1343 | + JSONArray ja1 = new JSONArray() |
| 1344 | + .put(new MyJsonString()) |
| 1345 | + .put(2); |
| 1346 | + JSONArray ja2 = new JSONArray() |
| 1347 | + .put(new MyJsonString()) |
| 1348 | + .put(2); |
| 1349 | + assertTrue(ja1.similar(ja2)); |
| 1350 | + |
| 1351 | + JSONArray ja3 = new JSONArray() |
| 1352 | + .put(new JSONString() { |
| 1353 | + @Override |
| 1354 | + public String toJSONString() { |
| 1355 | + return "\"different value\""; |
| 1356 | + } |
| 1357 | + }) |
| 1358 | + .put(2); |
| 1359 | + assertFalse(ja1.similar(ja3)); |
| 1360 | + } |
1337 | 1361 | } |
0 commit comments