use of org.antlr.v4.runtime.CodePointCharStream in project antlr4 by antlr.
the class TestCodePointCharStream method seekWithCJK.
@Test
public void seekWithCJK() {
CodePointCharStream s = CharStreams.fromString("01234䂔6789");
s.seek(5);
assertEquals(0x4094, s.LA(1));
}
use of org.antlr.v4.runtime.CodePointCharStream in project antlr4 by antlr.
the class TestCodePointCharStream method lookBehindWithEmoji.
@Test
public void lookBehindWithEmoji() {
CodePointCharStream s = CharStreams.fromString(new StringBuilder("01234").appendCodePoint(0x1F522).append("6789").toString());
s.seek(6);
assertEquals(0x1F522, s.LA(-1));
}
use of org.antlr.v4.runtime.CodePointCharStream in project antlr4 by antlr.
the class TestCodePointCharStream method consumingPastSingleCJKCodePointShouldThrow.
@Test
public void consumingPastSingleCJKCodePointShouldThrow() {
CodePointCharStream s = CharStreams.fromString("愛");
s.consume();
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 lookAheadWithEmoji.
@Test
public void lookAheadWithEmoji() {
CodePointCharStream s = CharStreams.fromString(new StringBuilder("01234").appendCodePoint(0x1F522).append("6789").toString());
assertEquals(0x1F522, s.LA(6));
}
use of org.antlr.v4.runtime.CodePointCharStream in project antlr4 by antlr.
the class TestCodePointCharStream method multipleLatinCodePointsLookAheadShouldReturnCodePoints.
@Test
public void multipleLatinCodePointsLookAheadShouldReturnCodePoints() {
CodePointCharStream s = CharStreams.fromString("XYZ");
assertEquals('X', s.LA(1));
assertEquals(0, s.index());
assertEquals('Y', s.LA(2));
assertEquals(0, s.index());
assertEquals('Z', s.LA(3));
assertEquals(0, s.index());
}
Aggregations