use of org.antlr.v4.runtime.CharStream in project antlr4 by tunnelvisionlabs.
the class TestUnbufferedCharStream method testGetTextBeforeBufferStart.
@Test(expected = UnsupportedOperationException.class)
public void testGetTextBeforeBufferStart() {
CharStream input = createStream("xyz");
input.consume();
int m1 = input.mark();
assertEquals(1, input.index());
input.getText(new Interval(0, 1));
}
use of org.antlr.v4.runtime.CharStream in project antlr4 by tunnelvisionlabs.
the class TestUnbufferedCharStream method testNoChar.
@Test
public void testNoChar() throws Exception {
CharStream input = createStream("");
assertEquals(IntStream.EOF, input.LA(1));
assertEquals(IntStream.EOF, input.LA(2));
}
use of org.antlr.v4.runtime.CharStream in project antlr4 by tunnelvisionlabs.
the class TestUnbufferedCharStream method testBufferWrapSize1.
@Test
public void testBufferWrapSize1() throws Exception {
CharStream input = createStream("01234", 1);
assertEquals('0', input.LA(1));
input.consume();
assertEquals('1', input.LA(1));
input.consume();
assertEquals('2', input.LA(1));
input.consume();
assertEquals('3', input.LA(1));
input.consume();
assertEquals('4', input.LA(1));
input.consume();
assertEquals(IntStream.EOF, input.LA(1));
}
use of org.antlr.v4.runtime.CharStream in project antlr4 by tunnelvisionlabs.
the class TestUnbufferedCharStream method testMarkReleaseOutOfOrder.
/**
* The {@link IntStream} interface does not specify the behavior when marks
* are not released in the reversed order they were created, but
* {@link UnbufferedCharStream} handles this case by throwing an
* {@link IllegalStateException}.
*/
@Test(expected = IllegalStateException.class)
public void testMarkReleaseOutOfOrder() {
CharStream input = createStream("");
int m1 = input.mark();
int m2 = input.mark();
input.release(m1);
}
use of org.antlr.v4.runtime.CharStream in project antlr4 by tunnelvisionlabs.
the class TestUnbufferedCharStream method test2CharAhead.
@Test
public void test2CharAhead() throws Exception {
CharStream input = createStream("xy");
assertEquals('x', input.LA(1));
assertEquals('y', input.LA(2));
assertEquals(IntStream.EOF, input.LA(3));
}
Aggregations