use of org.antlr.v4.runtime.misc.IntervalSet in project antlr4 by antlr.
the class TestIntervalSet method testSubtractOfCompletelyCoveredRange.
@Test
public void testSubtractOfCompletelyCoveredRange() throws Exception {
IntervalSet s = IntervalSet.of(10, 20);
IntervalSet s2 = IntervalSet.of(1, 25);
String expecting = "{}";
String result = (s.subtract(s2)).toString();
assertEquals(expecting, result);
}
use of org.antlr.v4.runtime.misc.IntervalSet in project antlr4 by antlr.
the class TestIntervalSet method testNotSet.
@Test
public void testNotSet() throws Exception {
IntervalSet vocabulary = IntervalSet.of(1, 1000);
IntervalSet s = IntervalSet.of(50, 60);
s.add(5);
s.add(250, 300);
String expecting = "{1..4, 6..49, 61..249, 301..1000}";
String result = (s.complement(vocabulary)).toString();
assertEquals(expecting, result);
}
use of org.antlr.v4.runtime.misc.IntervalSet in project antlr4 by antlr.
the class TestIntervalSet method testRmRightSide.
@Test
public void testRmRightSide() throws Exception {
IntervalSet s = IntervalSet.of(1, 10);
s.add(-3, -3);
s.remove(10);
String expecting = "{-3, 1..9}";
String result = s.toString();
assertEquals(expecting, result);
}
use of org.antlr.v4.runtime.misc.IntervalSet in project antlr4 by antlr.
the class TestIntervalSet method testToList.
@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);
}
use of org.antlr.v4.runtime.misc.IntervalSet in project antlr4 by antlr.
the class TestIntervalSet method testSubtractOfOverlappingRangeFromRight.
@Test
public void testSubtractOfOverlappingRangeFromRight() throws Exception {
IntervalSet s = IntervalSet.of(10, 20);
IntervalSet s2 = IntervalSet.of(15, 25);
String expecting = "{10..14}";
String result = (s.subtract(s2)).toString();
assertEquals(expecting, result);
IntervalSet s3 = IntervalSet.of(20, 25);
expecting = "{10..19}";
result = (s.subtract(s3)).toString();
assertEquals(expecting, result);
}
Aggregations