File tree Expand file tree Collapse file tree
src/test/java/org/json/junit Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -130,10 +130,13 @@ public void verifySimilar() {
130130 assertTrue ("obj1-obj3 Should eval to true" , obj1 .similar (obj3 ));
131131 assertTrue ("obj1-obj4 Should eval to true" , obj1 .similar (obj4 ));
132132 assertFalse ("obj1-obj5 Should eval to false" , obj1 .similar (obj5 ));
133-
134133 // verify that a double and big decimal are "similar"
135134 assertTrue ("should eval to true" ,new JSONObject ().put ("a" ,1.1d ).similar (new JSONObject ("{\" a\" :1.1}" )));
136-
135+ // Confirm #618 is fixed (compare should not exit early if similar numbers are found)
136+ // Note that this test may not work if the JSONObject map entry order changes
137+ JSONObject first = new JSONObject ("{\" a\" : 1, \" b\" : 2, \" c\" : 3}" );
138+ JSONObject second = new JSONObject ("{\" a\" : 1, \" b\" : 2.0, \" c\" : 4}" );
139+ assertFalse ("first-second should eval to false" , first .similar (second ));
137140 }
138141
139142 @ Test
You can’t perform that action at this time.
0 commit comments