Skip to content

Commit 8680b10

Browse files
committed
merge from master to pick up stleary#616 and add one more test
1 parent 2559114 commit 8680b10

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/test/java/org/json/junit/JSONObjectTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)