Skip to content

Commit

Permalink
more unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rikkarth committed Aug 6, 2024
1 parent 778f134 commit 2bb346b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/test/java/org/json/junit/JSONParserConfigurationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ public void givenInvalidJsonObjects_testStrictModeTrue_shouldThrowJsonException(
() -> new JSONObject(jsonObject, new JSONParserConfiguration().withStrictMode(true))));
}

@Test
public void givenValidArraysWithInvalidJsonObjects_testStrictMode_shouldThrowJsonException(){
final List<String> 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<String> jsonPaths = Arrays.asList(
Expand Down

0 comments on commit 2bb346b

Please sign in to comment.