use of org.antlr.v4.runtime.misc.IntervalSet in project antlr4 by antlr.
the class TestIntervalSet method testSingleElementMinusDisjointSet.
@Test
public void testSingleElementMinusDisjointSet() throws Exception {
IntervalSet s = IntervalSet.of(15, 15);
IntervalSet s2 = IntervalSet.of(1, 5);
s2.add(10, 20);
// 15 - {1..5, 10..20} = {}
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 testRmMiddleRange.
@Test
public void testRmMiddleRange() throws Exception {
IntervalSet s = IntervalSet.of(1, 10);
s.add(-3, -3);
s.remove(5);
String expecting = "{-3, 1..4, 6..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 testSize.
@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(expecting, result);
}
use of org.antlr.v4.runtime.misc.IntervalSet in project antlr4 by antlr.
the class TestIntervalSet method testNotEqualSet.
@Test
public void testNotEqualSet() throws Exception {
IntervalSet vocabulary = IntervalSet.of(1, 1000);
IntervalSet s = IntervalSet.of(1, 1000);
String expecting = "{}";
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 testComplement2.
@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);
}
Aggregations