Package org.antlr.v4.runtime.misc

Examples of org.antlr.v4.runtime.misc.IntervalSet


    assertEquals(expecting, result);
  }

    @Test public void testMergeOfRangesAndSingleValues() throws Exception {
        // {0..41, 42, 43..65534}
        IntervalSet s = IntervalSet.of(0,41);
        s.add(42);
        s.add(43,65534);
        String expecting = "{0..65534}";
        String result = s.toString();
        assertEquals(expecting, result);
    }
View Full Code Here


        String result = s.toString();
        assertEquals(expecting, result);
    }

    @Test public void testMergeOfRangesAndSingleValuesReverse() throws Exception {
        IntervalSet s = IntervalSet.of(43,65534);
        s.add(42);
        s.add(0,41);
        String expecting = "{0..65534}";
        String result = s.toString();
        assertEquals(expecting, result);
    }
View Full Code Here

        assertEquals(expecting, result);
    }

    @Test public void testMergeWhereAdditionMergesTwoExistingIntervals() throws Exception {
        // 42, 10, {0..9, 11..41, 43..65534}
        IntervalSet s = IntervalSet.of(42);
        s.add(10);
        s.add(0,9);
        s.add(43,65534);
        s.add(11,41);
        String expecting = "{0..65534}";
        String result = s.toString();
        assertEquals(expecting, result);
    }
View Full Code Here

  /**
   * This case is responsible for antlr/antlr4#153.
   * https://github.com/antlr/antlr4/issues/153
   */
  @Test public void testMergeWhereAdditionMergesThreeExistingIntervals() throws Exception {
    IntervalSet s = new IntervalSet();
    s.add(0);
    s.add(3);
    s.add(5);
    s.add(0, 7);
    String expecting = "{0..7}";
    String result = s.toString();
    assertEquals(expecting, result);
  }
View Full Code Here

    String result = s.toString();
    assertEquals(expecting, result);
  }

  @Test public void testMergeWithDoubleOverlap() throws Exception {
    IntervalSet s = IntervalSet.of(1,10);
    s.add(20,30);
    s.add(5,25); // overlaps two!
    String expecting = "{1..30}";
    String result = s.toString();
    assertEquals(expecting, result);
  }
View Full Code Here

    String result = s.toString();
    assertEquals(expecting, result);
  }

  @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);
  }
View Full Code Here

    String result = String.valueOf(s.size());
    assertEquals(expecting, result);
  }

  @Test public void testToList() throws Exception {
    IntervalSet s = IntervalSet.of(20,25);
    s.add(50,55);
    s.add(5,5);
    String expecting = "[5, 20, 21, 22, 23, 24, 25, 50, 51, 52, 53, 54, 55]";
    String result = String.valueOf(s.toList());
    assertEquals(expecting, result);
  }
View Full Code Here

      {'\u0000'..'q', 's'}!!!! broken...
     'q' is 113 ascii
     'u' is 117
  */
  @Test public void testNotRIntersectionNotT() throws Exception {
    IntervalSet s = IntervalSet.of(0,'s');
    s.add('u',200);
    IntervalSet s2 = IntervalSet.of(0,'q');
    s2.add('s',200);
    String expecting = "{0..113, 115, 117..200}";
    String result = (s.and(s2)).toString();
    assertEquals(expecting, result);
  }
View Full Code Here

    String result = (s.and(s2)).toString();
    assertEquals(expecting, result);
  }

    @Test public void testRmSingleElement() throws Exception {
        IntervalSet s = IntervalSet.of(1,10);
        s.add(-3,-3);
        s.remove(-3);
        String expecting = "{1..10}";
        String result = s.toString();
        assertEquals(expecting, result);
    }
View Full Code Here

        String result = s.toString();
        assertEquals(expecting, result);
    }

    @Test public void testRmLeftSide() throws Exception {
        IntervalSet s = IntervalSet.of(1,10);
        s.add(-3,-3);
        s.remove(1);
        String expecting = "{-3, 2..10}";
        String result = s.toString();
        assertEquals(expecting, result);
    }
View Full Code Here

TOP

Related Classes of org.antlr.v4.runtime.misc.IntervalSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.