Package org.antlr.misc

Examples of org.antlr.misc.IntervalSet


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

    @Test public void testMembership() throws Exception {
        IntervalSet s = IntervalSet.of(15,15);
        s.add(50,60);
        assertTrue(!s.member(0));
        assertTrue(!s.member(20));
        assertTrue(!s.member(100));
        assertTrue(s.member(15));
        assertTrue(s.member(55));
        assertTrue(s.member(50));
        assertTrue(s.member(60));
    }
View Full Code Here


        assertTrue(s.member(60));
    }

    // {2,15,18} & 10..20
    @Test public void testIntersectionWithTwoContainedElements() throws Exception {
        IntervalSet s = IntervalSet.of(10,20);
        IntervalSet s2 = IntervalSet.of(2,2);
        s2.add(15);
        s2.add(18);
        String expecting = "{15, 18}";
        String result = (s.and(s2)).toString();
        assertEquals(result, expecting);
    }
View Full Code Here

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

    @Test public void testIntersectionWithTwoContainedElementsReversed() throws Exception {
        IntervalSet s = IntervalSet.of(10,20);
        IntervalSet s2 = IntervalSet.of(2,2);
        s2.add(15);
        s2.add(18);
        String expecting = "{15, 18}";
        String result = (s2.and(s)).toString();
        assertEquals(result, expecting);
    }
View Full Code Here

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

    @Test public void testComplement() throws Exception {
        IntervalSet s = IntervalSet.of(100,100);
        s.add(101,101);
        IntervalSet s2 = IntervalSet.of(100,102);
        String expecting = "102";
        String result = (s.complement(s2)).toString();
        assertEquals(result, expecting);
    }
View Full Code Here

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

  @Test public void testComplement2() throws Exception {
    IntervalSet s = IntervalSet.of(100,101);
    IntervalSet s2 = IntervalSet.of(100,102);
    String expecting = "102";
    String result = (s.complement(s2)).toString();
    assertEquals(result, expecting);
  }
View Full Code Here

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

  @Test public void testComplement3() throws Exception {
    IntervalSet s = IntervalSet.of(1,96);
    s.add(99,Label.MAX_CHAR_VALUE);
    String expecting = "97..98";
    String result = (s.complement(1,Label.MAX_CHAR_VALUE)).toString();
    assertEquals(result, expecting);
  }
View Full Code Here

    assertEquals(result, expecting);
  }

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

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

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

        assertEquals(result, expecting);
    }

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

   * https://github.com/antlr/antlr4/issues/153
   * <p>
   * Resolution back-ported from V4.</p>
   */
  @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

TOP

Related Classes of org.antlr.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.