Skip to content

Commit 7145c69

Browse files
committed
add test
1 parent 86f0b2b commit 7145c69

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4044,4 +4044,21 @@ public void jsonObjectParseNullFieldsWithoutParserConfiguration() {
40444044
assertTrue("JSONObject should be empty", jsonObject.isEmpty());
40454045
}
40464046

4047+
/**
4048+
* Testing that a custom map extension works.
4049+
*/
4050+
@Test
4051+
public void jsonObjectOrderedTest() {
4052+
JSONObject jsonObject = new JSONObject() {
4053+
@Override
4054+
public Map<String, Object> newInternalMap(int capacity) {
4055+
return new LinkedHashMap<>();
4056+
}
4057+
};
4058+
jsonObject.put("a", 1)
4059+
.put("c", 2)
4060+
.put("b", 3)
4061+
.put("d", 4);
4062+
assertEquals("{\"a\":1,\"c\":2,\"b\":3,\"d\":4}", jsonObject.toString());
4063+
}
40474064
}

0 commit comments

Comments
 (0)