use of org.antlr.v4.runtime.misc.IntervalSet in project antlr4 by antlr.
the class TestIntervalSet method testSubtractOfWackyRange.
/** 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);
}
use of org.antlr.v4.runtime.misc.IntervalSet in project antlr4 by antlr.
the class TestIntervalSet method testEquals.
@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));
}
use of org.antlr.v4.runtime.misc.IntervalSet in project antlr4 by antlr.
the class TestIntervalSet method testMergeWhereAdditionMergesTwoExistingIntervals.
@Test
public void testMergeWhereAdditionMergesTwoExistingIntervals() throws Exception {
// 42, 10, {0..9, 11..41, 43..65534}
IntervalSet s = IntervalSet.of(42);
s.add(10);
s.add(0, 9);
s.add(43, 65534);
s.add(11, 41);
String expecting = "{0..65534}";
String result = s.toString();
assertEquals(expecting, result);
}
use of org.antlr.v4.runtime.misc.IntervalSet in project antlr4 by antlr.
the class TestIntervalSet method testMergeOfRangesAndSingleValues.
@Test
public void testMergeOfRangesAndSingleValues() throws Exception {
// {0..41, 42, 43..65534}
IntervalSet s = IntervalSet.of(0, 41);
s.add(42);
s.add(43, 65534);
String expecting = "{0..65534}";
String result = s.toString();
assertEquals(expecting, result);
}
use of org.antlr.v4.runtime.misc.IntervalSet in project antlr4 by antlr.
the class TestIntervalSet method testSingleElement.
@Test
public void testSingleElement() throws Exception {
IntervalSet s = IntervalSet.of(99);
String expecting = "99";
assertEquals(s.toString(), expecting);
}
Aggregations