use of org.antlr.v4.runtime.misc.IntervalSet in project antlr4 by antlr.
the class TestIntervalSet method testRmLeftSide.
@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);
}
use of org.antlr.v4.runtime.misc.IntervalSet in project antlr4 by antlr.
the class TestIntervalSet method testIsolatedElements.
@Test
public void testIsolatedElements() throws Exception {
IntervalSet s = new IntervalSet();
s.add(1);
s.add('z');
s.add('');
String expecting = "{1, 122, 65520}";
assertEquals(s.toString(), expecting);
}
use of org.antlr.v4.runtime.misc.IntervalSet in project antlr4 by antlr.
the class TestIntervalSet method testIntersectionWithTwoContainedElements.
// {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);
}
use of org.antlr.v4.runtime.misc.IntervalSet in project antlr4 by antlr.
the class TestIntervalSet method testSubtractOfOverlappingRangeFromLeft.
@Test
public void testSubtractOfOverlappingRangeFromLeft() throws Exception {
IntervalSet s = IntervalSet.of(10, 20);
IntervalSet s2 = IntervalSet.of(5, 11);
String expecting = "{12..20}";
String result = (s.subtract(s2)).toString();
assertEquals(expecting, result);
IntervalSet s3 = IntervalSet.of(5, 10);
expecting = "{11..20}";
result = (s.subtract(s3)).toString();
assertEquals(expecting, result);
}
use of org.antlr.v4.runtime.misc.IntervalSet in project antlr4 by antlr.
the class TestIntervalSet method testMergeOfRangesAndSingleValuesReverse.
@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);
}
Aggregations