Package org.antlr.misc

Examples of org.antlr.misc.IntervalSet


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

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


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

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

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

  @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]";
    List foo = new ArrayList();
    String result = String.valueOf(s.toList());
    assertEquals(result, expecting);
  }
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(result, expecting);
  }
View Full Code Here

    /** Public default constructor used by TestRig */
    public TestIntervalSet() {
    }

    @Test public void testSingleElement() throws Exception {
        IntervalSet s = IntervalSet.of(99);
        String expecting = "99";
        assertEquals(s.toString(), expecting);
    }
View Full Code Here

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

    @Test public void testIsolatedElements() throws Exception {
        IntervalSet s = new IntervalSet();
        s.add(1);
        s.add('z');
        s.add('\uFFF0');
        String expecting = "{1, 122, 65520}";
        assertEquals(s.toString(), expecting);
    }
View Full Code Here

        String expecting = "{1, 122, 65520}";
        assertEquals(s.toString(), expecting);
    }

    @Test public void testMixedRangesAndElements() throws Exception {
        IntervalSet s = new IntervalSet();
        s.add(1);
        s.add('a','z');
        s.add('0','9');
        String expecting = "{1, 48..57, 97..122}";
        assertEquals(s.toString(), expecting);
    }
View Full Code Here

        String expecting = "{1, 48..57, 97..122}";
        assertEquals(s.toString(), expecting);
    }

    @Test public void testSimpleAnd() throws Exception {
        IntervalSet s = IntervalSet.of(10,20);
        IntervalSet s2 = IntervalSet.of(13,15);
        String expecting = "13..15";
        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 testRangeAndIsolatedElement() throws Exception {
        IntervalSet s = IntervalSet.of('a','z');
        IntervalSet s2 = IntervalSet.of('d');
        String expecting = "100";
        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 testEmptyIntersection() throws Exception {
    IntervalSet s = IntervalSet.of('a','z');
    IntervalSet s2 = IntervalSet.of('0','9');
    String expecting = "{}";
    String result = (s.and(s2)).toString();
    assertEquals(result, expecting);
  }
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.