Skip to content

Commit

Permalink
merge from master to pick up #616 and add one more test
Browse files Browse the repository at this point in the history
  • Loading branch information
stleary committed Jul 26, 2021
1 parent 2559114 commit 8680b10
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/test/java/org/json/junit/JSONObjectTest.java
Expand Up @@ -130,10 +130,13 @@ public void verifySimilar() {
assertTrue("obj1-obj3 Should eval to true", obj1.similar(obj3));
assertTrue("obj1-obj4 Should eval to true", obj1.similar(obj4));
assertFalse("obj1-obj5 Should eval to false", obj1.similar(obj5));

// verify that a double and big decimal are "similar"
assertTrue("should eval to true",new JSONObject().put("a",1.1d).similar(new JSONObject("{\"a\":1.1}")));

// Confirm #618 is fixed (compare should not exit early if similar numbers are found)
// Note that this test may not work if the JSONObject map entry order changes
JSONObject first = new JSONObject("{\"a\": 1, \"b\": 2, \"c\": 3}");
JSONObject second = new JSONObject("{\"a\": 1, \"b\": 2.0, \"c\": 4}");
assertFalse("first-second should eval to false", first.similar(second));
}

@Test
Expand Down

0 comments on commit 8680b10

Please sign in to comment.