Skip to content

Commit 2bb346b

Browse files
committed
more unit-tests
1 parent 778f134 commit 2bb346b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,19 @@ public void givenInvalidJsonObjects_testStrictModeTrue_shouldThrowJsonException(
5858
() -> new JSONObject(jsonObject, new JSONParserConfiguration().withStrictMode(true))));
5959
}
6060

61+
@Test
62+
public void givenValidArraysWithInvalidJsonObjects_testStrictMode_shouldThrowJsonException(){
63+
final List<String> jsonArrays = Arrays.asList(
64+
"[1, {}}]",
65+
"[1, 2, 3, \"value\", true]abc",
66+
"[{}, {\"key\":\"value\"}abc]"
67+
);
68+
69+
jsonArrays.forEach(jsonArray ->
70+
assertThrows(JSONException.class,
71+
() -> new JSONArray(jsonArray, new JSONParserConfiguration().withStrictMode(true))));
72+
}
73+
6174
@Test
6275
public void givenValidJsonObjects_testStrictModeTrue() {
6376
final List<String> jsonPaths = Arrays.asList(

0 commit comments

Comments
 (0)