@@ -26,6 +26,7 @@ of this software and associated documentation files (the "Software"), to deal
2626
2727import static org .junit .Assert .assertEquals ;
2828import static org .junit .Assert .assertFalse ;
29+ import static org .junit .Assert .assertNotEquals ;
2930import static org .junit .Assert .assertNotNull ;
3031import static org .junit .Assert .assertNull ;
3132import static org .junit .Assert .assertTrue ;
@@ -49,7 +50,9 @@ of this software and associated documentation files (the "Software"), to deal
4950import org .json .JSONException ;
5051import org .json .JSONObject ;
5152import org .json .JSONPointerException ;
53+ import org .json .JSONString ;
5254import org .json .JSONTokener ;
55+ import org .json .junit .data .MyJsonString ;
5356import org .junit .Test ;
5457
5558import com .jayway .jsonpath .Configuration ;
@@ -1354,4 +1357,25 @@ public void issue654StackOverflowInputWellFormed() {
13541357 fail ("Excepected Exception." );
13551358 Util .checkJSONArrayMaps (json_input );
13561359 }
1360+
1361+ @ Test
1362+ public void testIssue682SimilarityOfJSONString () {
1363+ JSONArray ja1 = new JSONArray ()
1364+ .put (new MyJsonString ())
1365+ .put (2 );
1366+ JSONArray ja2 = new JSONArray ()
1367+ .put (new MyJsonString ())
1368+ .put (2 );
1369+ assertTrue (ja1 .similar (ja2 ));
1370+
1371+ JSONArray ja3 = new JSONArray ()
1372+ .put (new JSONString () {
1373+ @ Override
1374+ public String toJSONString () {
1375+ return "\" different value\" " ;
1376+ }
1377+ })
1378+ .put (2 );
1379+ assertFalse (ja1 .similar (ja3 ));
1380+ }
13571381}
0 commit comments