Search in sources :

Example 16 with Result

use of org.antlr.v4.misc.EscapeSequenceParsing.Result in project antlr4 by antlr.

the class TestIntervalSet method testSubtractOfCompletelyContainedRange.

@Test
public void testSubtractOfCompletelyContainedRange() throws Exception {
    IntervalSet s = IntervalSet.of(10, 20);
    IntervalSet s2 = IntervalSet.of(12, 15);
    String expecting = "{10..11, 16..20}";
    String result = (s.subtract(s2)).toString();
    assertEquals(expecting, result);
}
Also used : IntervalSet(org.antlr.v4.runtime.misc.IntervalSet) Test(org.junit.Test)

Example 17 with Result

use of org.antlr.v4.misc.EscapeSequenceParsing.Result in project antlr4 by antlr.

the class TestIntervalSet method testSingleElementMinusDisjointSet.

@Test
public void testSingleElementMinusDisjointSet() throws Exception {
    IntervalSet s = IntervalSet.of(15, 15);
    IntervalSet s2 = IntervalSet.of(1, 5);
    s2.add(10, 20);
    // 15 - {1..5, 10..20} = {}
    String expecting = "{}";
    String result = s.subtract(s2).toString();
    assertEquals(expecting, result);
}
Also used : IntervalSet(org.antlr.v4.runtime.misc.IntervalSet) Test(org.junit.Test)

Example 18 with Result

use of org.antlr.v4.misc.EscapeSequenceParsing.Result in project antlr4 by antlr.

the class TestIntervalSet method testRmMiddleRange.

@Test
public void testRmMiddleRange() throws Exception {
    IntervalSet s = IntervalSet.of(1, 10);
    s.add(-3, -3);
    s.remove(5);
    String expecting = "{-3, 1..4, 6..10}";
    String result = s.toString();
    assertEquals(expecting, result);
}
Also used : IntervalSet(org.antlr.v4.runtime.misc.IntervalSet) Test(org.junit.Test)

Example 19 with Result

use of org.antlr.v4.misc.EscapeSequenceParsing.Result in project antlr4 by antlr.

the class TestIntervalSet method testSize.

@Test
public void testSize() throws Exception {
    IntervalSet s = IntervalSet.of(20, 30);
    s.add(50, 55);
    s.add(5, 19);
    String expecting = "32";
    String result = String.valueOf(s.size());
    assertEquals(expecting, result);
}
Also used : IntervalSet(org.antlr.v4.runtime.misc.IntervalSet) Test(org.junit.Test)

Example 20 with Result

use of org.antlr.v4.misc.EscapeSequenceParsing.Result in project antlr4 by antlr.

the class TestIntervalSet method testNotEqualSet.

@Test
public void testNotEqualSet() throws Exception {
    IntervalSet vocabulary = IntervalSet.of(1, 1000);
    IntervalSet s = IntervalSet.of(1, 1000);
    String expecting = "{}";
    String result = (s.complement(vocabulary)).toString();
    assertEquals(expecting, result);
}
Also used : IntervalSet(org.antlr.v4.runtime.misc.IntervalSet) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)131 LexerGrammar (org.antlr.v4.tool.LexerGrammar)78 ANTLRInputStream (org.antlr.v4.runtime.ANTLRInputStream)52 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)49 LexerInterpreter (org.antlr.v4.runtime.LexerInterpreter)44 ATN (org.antlr.v4.runtime.atn.ATN)44 TokenStreamRewriter (org.antlr.v4.runtime.TokenStreamRewriter)38 IntervalSet (org.antlr.v4.runtime.misc.IntervalSet)38 BaseJavaTest (org.antlr.v4.test.runtime.java.BaseJavaTest)38 ParseTree (org.antlr.v4.runtime.tree.ParseTree)29 ATNState (org.antlr.v4.runtime.atn.ATNState)11 Grammar (org.antlr.v4.tool.Grammar)10 STGroupString (org.stringtemplate.v4.STGroupString)10 ByteBuffer (java.nio.ByteBuffer)8 IntBuffer (java.nio.IntBuffer)8 UTF8CodePointDecoder (org.antlr.v4.runtime.UTF8CodePointDecoder)8 BaseRuntimeTest.antlrOnString (org.antlr.v4.test.runtime.BaseRuntimeTest.antlrOnString)8 DOTGenerator (org.antlr.v4.tool.DOTGenerator)8 ParserATNFactory (org.antlr.v4.automata.ParserATNFactory)7 Rule (org.antlr.v4.tool.Rule)7