@@ -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 ;
@@ -1298,4 +1301,25 @@ public void issue654StackOverflowInputWellFormed() {
12981301 assertNotNull (json_input );
12991302 fail ("Excepected Exception." );
13001303 }
1304+
1305+ @ Test
1306+ public void testIssue682SimilarityOfJSONString () {
1307+ JSONArray ja1 = new JSONArray ()
1308+ .put (new MyJsonString ())
1309+ .put (2 );
1310+ JSONArray ja2 = new JSONArray ()
1311+ .put (new MyJsonString ())
1312+ .put (2 );
1313+ assertTrue (ja1 .similar (ja2 ));
1314+
1315+ JSONArray ja3 = new JSONArray ()
1316+ .put (new JSONString () {
1317+ @ Override
1318+ public String toJSONString () {
1319+ return "\" different value\" " ;
1320+ }
1321+ })
1322+ .put (2 );
1323+ assertFalse (ja1 .similar (ja3 ));
1324+ }
13011325}
0 commit comments