use of org.antlr.v4.runtime.CodePointCharStream in project antlr4 by antlr.
the class TestCodePointCharStream method emptyBytesHasSize0.
@Test
public void emptyBytesHasSize0() {
CodePointCharStream s = CharStreams.fromString("");
assertEquals(0, s.size());
assertEquals(0, s.index());
}
use of org.antlr.v4.runtime.CodePointCharStream in project antlr4 by antlr.
the class TestCodePointCharStream method singleCJKCodePointLookAheadPastEndShouldReturnEOF.
@Test
public void singleCJKCodePointLookAheadPastEndShouldReturnEOF() {
CodePointCharStream s = CharStreams.fromString("愛");
assertEquals(IntStream.EOF, s.LA(2));
assertEquals(0, s.index());
}
use of org.antlr.v4.runtime.CodePointCharStream in project antlr4 by antlr.
the class TestCodePointCharStream method consumingPastEndOfEmojiCodePointWithShouldThrow.
@Test
public void consumingPastEndOfEmojiCodePointWithShouldThrow() {
CodePointCharStream s = CharStreams.fromString(new StringBuilder().appendCodePoint(0x1F4A9).toString());
assertEquals(0, s.index());
s.consume();
assertEquals(1, s.index());
thrown.expect(IllegalStateException.class);
thrown.expectMessage("cannot consume EOF");
s.consume();
}
use of org.antlr.v4.runtime.CodePointCharStream in project antlr4 by antlr.
the class TestCodePointCharStream method lookAheadWithCJK.
@Test
public void lookAheadWithCJK() {
CodePointCharStream s = CharStreams.fromString("01234䂔6789");
assertEquals(0x4094, s.LA(6));
}
use of org.antlr.v4.runtime.CodePointCharStream in project antlr4 by antlr.
the class TestCodePointCharStream method consumingPastSingleLatinCodePointShouldThrow.
@Test
public void consumingPastSingleLatinCodePointShouldThrow() {
CodePointCharStream s = CharStreams.fromString("X");
s.consume();
thrown.expect(IllegalStateException.class);
thrown.expectMessage("cannot consume EOF");
s.consume();
}
Aggregations