Skip to content

Commit 52ecc89

Browse files
committed
New test to verify unclosed array
1 parent af3b7dc commit 52ecc89

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,21 @@ public void emptStr() {
7979
e.getMessage());
8080
}
8181
}
82+
83+
/**
84+
* Attempt to create a JSONArray with an unclosed array.
85+
* Expects an exception
86+
*/
87+
@Test
88+
public void unclosedArray() {
89+
try {
90+
assertNull("Should throw an exception", new JSONArray("["));
91+
} catch (JSONException e) {
92+
assertEquals("Expected an exception message",
93+
"A JSONArray text must start with '[' at 0 [character 1 line 1]",
94+
e.getMessage());
95+
}
96+
}
8297

8398
/**
8499
* Attempt to create a JSONArray with a string as object that is

0 commit comments

Comments
 (0)