Skip to content

Commit

Permalink
add test for invalid input on JSONTokener
Browse files Browse the repository at this point in the history
expect JSONException but got NullPointerException
  • Loading branch information
Simulant87 committed Jan 8, 2025
1 parent 391c869 commit 20a6340
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/test/java/org/json/junit/JSONTokenerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,11 @@ public void testAutoClose(){
assertEquals("Stream closed", exception.getMessage());
}
}

@Test
public void testInvalidInput_shouldThrowJSONException() {
String input = "{\"invalidInput\": [],}";
JSONTokener tokener = new JSONTokener(input);
assertThrows(JSONException.class, () -> tokener.nextValue());
}
}

0 comments on commit 20a6340

Please sign in to comment.