File tree Expand file tree Collapse file tree
gson/src/test/java/com/google/gson/internal/bind Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -281,4 +281,25 @@ public void testOverrides() {
281281 "getSerializeNulls()" );
282282 MoreAsserts .assertOverridesMethods (JsonWriter .class , JsonTreeWriter .class , ignoredMethods );
283283 }
284+
285+ @ Test
286+ public void testEndArrayOnEmptyStackThrows () {
287+ JsonTreeWriter writer = new JsonTreeWriter ();
288+ assertThrows (IllegalStateException .class , () -> writer .endArray ());
289+ }
290+
291+ @ Test
292+ public void testEndArrayWithPendingNameThrows () throws IOException {
293+ JsonTreeWriter writer = new JsonTreeWriter ();
294+ writer .beginObject ();
295+ writer .name ("test" );
296+ assertThrows (IllegalStateException .class , () -> writer .endArray ());
297+ }
298+
299+ @ Test
300+ public void testEndArrayWhenStackTopIsNotArrayThrows () throws IOException {
301+ JsonTreeWriter writer = new JsonTreeWriter ();
302+ writer .beginObject ();
303+ assertThrows (IllegalStateException .class , () -> writer .endArray ());
304+ }
284305}
You can’t perform that action at this time.
0 commit comments