From c140e91bb8a433d8d15e537d205b5659e2197d1c Mon Sep 17 00:00:00 2001 From: rikkarth Date: Fri, 15 Mar 2024 01:23:20 +0000 Subject: [PATCH] test(#871-strictMode): strict mode false initial implementation --- .../org/json/junit/JSONParserConfigurationTest.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/json/junit/JSONParserConfigurationTest.java b/src/test/java/org/json/junit/JSONParserConfigurationTest.java index b4cf2cb..a37f5a4 100644 --- a/src/test/java/org/json/junit/JSONParserConfigurationTest.java +++ b/src/test/java/org/json/junit/JSONParserConfigurationTest.java @@ -31,7 +31,7 @@ public class JSONParserConfigurationTest { @Test public void givenInvalidInputArrays_testStrictModeTrue_shouldThrowJsonException() { - List strictModeInputTestCases = Arrays.asList("[1,2];[3,4]", "", "[1, 2,3]:[4,5]"/*, "[{test: implied}]"*/); + List strictModeInputTestCases = Arrays.asList("[1,2];[3,4]", "", "[1, 2,3]:[4,5]", "[{test: implied}]"); JSONParserConfiguration jsonParserConfiguration = new JSONParserConfiguration() .withStrictMode(true); @@ -43,6 +43,15 @@ public class JSONParserConfigurationTest { }); } + @Test + public void givenInvalidInputArrays_testStrictModeFalse_shouldNotThrowAnyException() { + List strictModeInputTestCases = Arrays.asList("[1,2];[3,4]", "[1, 2,3]:[4,5]", "[{test: implied}]"); + JSONParserConfiguration jsonParserConfiguration = new JSONParserConfiguration() + .withStrictMode(false); + + strictModeInputTestCases.stream().peek(System.out::println).forEach(testCase -> new JSONArray(testCase, jsonParserConfiguration)); + } + @Test public void verifyDuplicateKeyThenMaxDepth() { JSONParserConfiguration jsonParserConfiguration = new JSONParserConfiguration()