String result = (s.subtract(s2)).toString();
assertEquals(expecting, result);
}
@Test public void testSubtractOfRangeSpanningMultipleRanges() throws Exception {
IntervalSet s = IntervalSet.of(10,20);
s.add(30,40);
s.add(50,60); // s has 3 ranges now: 10..20, 30..40, 50..60
IntervalSet s2 = IntervalSet.of(5,55); // covers one and touches 2nd range
String expecting = "{56..60}";
String result = (s.subtract(s2)).toString();
assertEquals(expecting, result);
IntervalSet s3 = IntervalSet.of(15,55); // touches both
expecting = "{10..14, 56..60}";
result = (s.subtract(s3)).toString();
assertEquals(expecting, result);
}