use of org.antlr.v4.runtime.misc.IntervalSet in project antlr4 by antlr.
the class TestIntervalSet method testNotSingleElement.
@Test
public void testNotSingleElement() throws Exception {
IntervalSet vocabulary = IntervalSet.of(1, 1000);
vocabulary.add(2000, 3000);
IntervalSet s = IntervalSet.of(50, 50);
String expecting = "{1..49, 51..1000, 2000..3000}";
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 testSimpleEquals.
@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));
}
use of org.antlr.v4.runtime.misc.IntervalSet in project antlr4 by antlr.
the class TestIntervalSet method testEmptyIntersection.
@Test
public void testEmptyIntersection() throws Exception {
IntervalSet s = IntervalSet.of('a', 'z');
IntervalSet s2 = IntervalSet.of('0', '9');
String expecting = "{}";
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 testSubtractOfCompletelyContainedRange.
@Test
public void testSubtractOfCompletelyContainedRange() throws Exception {
IntervalSet s = IntervalSet.of(10, 20);
IntervalSet s2 = IntervalSet.of(12, 15);
String expecting = "{10..11, 16..20}";
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 testMixedRangesAndElements.
@Test
public void testMixedRangesAndElements() throws Exception {
IntervalSet s = new IntervalSet();
s.add(1);
s.add('a', 'z');
s.add('0', '9');
String expecting = "{1, 48..57, 97..122}";
assertEquals(s.toString(), expecting);
}
Aggregations