Package org.antlr.v4.runtime.misc

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


  /** The following was broken:
     {0..113, 115..65534}-{0..115, 117..65534}=116..65534
   */
  @Test public void testSubtractOfWackyRange() throws Exception {
    IntervalSet s = IntervalSet.of(0,113);
    s.add(115,200);
    IntervalSet s2 = IntervalSet.of(0,115);
    s2.add(117,200);
    String expecting = "116";
    String result = (s.subtract(s2)).toString();
    assertEquals(expecting, result);
  }
View Full Code Here


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

    @Test public void testSimpleEquals() throws Exception {
        IntervalSet s = IntervalSet.of(10,20);
        IntervalSet s2 = IntervalSet.of(10,20);
        assertEquals(s, s2);

        IntervalSet s3 = IntervalSet.of(15,55);
        assertFalse(s.equals(s3));
    }
View Full Code Here

        IntervalSet s3 = IntervalSet.of(15,55);
        assertFalse(s.equals(s3));
    }

    @Test public void testEquals() throws Exception {
        IntervalSet s = IntervalSet.of(10,20);
        s.add(2);
        s.add(499,501);
        IntervalSet s2 = IntervalSet.of(10,20);
        s2.add(2);
        s2.add(499,501);
        assertEquals(s, s2);

        IntervalSet s3 = IntervalSet.of(10,20);
        s3.add(2);
    assertFalse(s.equals(s3));
    }
View Full Code Here

        s3.add(2);
    assertFalse(s.equals(s3));
    }

    @Test public void testSingleElementMinusDisjointSet() throws Exception {
        IntervalSet s = IntervalSet.of(15,15);
        IntervalSet s2 = IntervalSet.of(1,5);
        s2.add(10,20);
        String expecting = "{}"; // 15 - {1..5, 10..20} = {}
        String result = s.subtract(s2).toString();
        assertEquals(expecting, result);
    }
View Full Code Here

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

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

        assertTrue(s.contains(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(expecting, result);
    }
View Full Code Here

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

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

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

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

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

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

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

  @Test public void testComplement3() throws Exception {
    IntervalSet s = IntervalSet.of(1,96);
    s.add(99, Lexer.MAX_CHAR_VALUE);
    String expecting = "{97..98}";
    String result = (s.complement(1, Lexer.MAX_CHAR_VALUE)).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.