From 2bb346b95fda9d59f08acfc69d9f445ecccdf4f9 Mon Sep 17 00:00:00 2001 From: rikkarth Date: Tue, 6 Aug 2024 15:46:59 +0100 Subject: [PATCH] more unit-tests --- .../org/json/junit/JSONParserConfigurationTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/test/java/org/json/junit/JSONParserConfigurationTest.java b/src/test/java/org/json/junit/JSONParserConfigurationTest.java index dfd9bf384..a93d62a06 100644 --- a/src/test/java/org/json/junit/JSONParserConfigurationTest.java +++ b/src/test/java/org/json/junit/JSONParserConfigurationTest.java @@ -58,6 +58,19 @@ public void givenInvalidJsonObjects_testStrictModeTrue_shouldThrowJsonException( () -> new JSONObject(jsonObject, new JSONParserConfiguration().withStrictMode(true)))); } + @Test + public void givenValidArraysWithInvalidJsonObjects_testStrictMode_shouldThrowJsonException(){ + final List jsonArrays = Arrays.asList( + "[1, {}}]", + "[1, 2, 3, \"value\", true]abc", + "[{}, {\"key\":\"value\"}abc]" + ); + + jsonArrays.forEach(jsonArray -> + assertThrows(JSONException.class, + () -> new JSONArray(jsonArray, new JSONParserConfiguration().withStrictMode(true)))); + } + @Test public void givenValidJsonObjects_testStrictModeTrue() { final List jsonPaths = Arrays.asList(