Skip to content

Commit

Permalink
Test #5: Test unespaced control flow characters in strict mode
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-voorberg committed Feb 24, 2023
1 parent 45692b9 commit 9effc31
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions gson/src/test/java/com/google/gson/stream/JsonReaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import java.io.Reader;
import java.io.StringReader;
import java.util.Arrays;

import org.checkerframework.common.value.qual.StaticallyExecutable;
import org.junit.Ignore;
import org.junit.Test;

Expand Down Expand Up @@ -100,6 +102,19 @@ public void testSkipArray() throws IOException {
assertThat(reader.peek()).isEqualTo(JsonToken.END_DOCUMENT);
}

@Test
public void testStrictModeFailsToParseUnespacedControlCharacter() {
String json = "\"\t\"";
JsonReader reader = new JsonReader(reader(json));
reader.setStrict(true);
try {
reader.nextString();
fail();
} catch (IOException e) {
assertThat(e.getMessage()).contains("strict");
}
}

@Test
public void testSkipArrayAfterPeek() throws Exception {
JsonReader reader = new JsonReader(reader(
Expand Down

0 comments on commit 9effc31

Please sign in to comment.