IntervalSet implements TimeSet<Interval> { @Override public boolean add(Interval interval) { return addInner(interval.getLow(), interval.getHigh()) >= 0; } IntervalSet();  IntervalSet(int capacity);  IntervalSet(double[] arr); @Override boolean add(Interval interval); @Override boolean remove(Interval interval); @Override int size(); @Override boolean isEmpty(); boolean contains(double timestamp); @Override boolean contains(Interval interval); double[] getIntervals(); @Override Interval[] toArray(); @Override Object toPrimitiveArray(); @Override void clear(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(TimeFormat timeFormat, DateTimeZone timeZone); @Override String toString(TimeFormat timeFormat); @Override String toString();  }
@Test public void testDuplicate() { IntervalSet set = new IntervalSet(); Assert.assertTrue(set.add(new Interval(0.0, 1.0))); Assert.assertFalse(set.add(new Interval(0.0, 1.0))); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testStartOverlappingAbove() { IntervalSet set = new IntervalSet(); Assert.assertTrue(set.add(new Interval(4.0, 5.0))); set.add(new Interval(4, 6)); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testStartOverlappingUnder() { IntervalSet set = new IntervalSet(); Assert.assertTrue(set.add(new Interval(0, 6))); set.add(new Interval(0, 5)); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testStartOverlappingContinuousAbove() { IntervalSet set = new IntervalSet(); Assert.assertTrue(set.add(new Interval(0.0, 1.0))); Assert.assertTrue(set.add(new Interval(1.0, 1.0))); Assert.assertTrue(set.add(new Interval(1.0, 2.0))); set.add(new Interval(1, 3)); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testStartOverlappingContinuousUnder() { IntervalSet set = new IntervalSet(); Assert.assertTrue(set.add(new Interval(0, 0))); Assert.assertTrue(set.add(new Interval(0, 6))); set.add(new Interval(0, 5)); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testEndOverlappingOdd() { IntervalSet set = new IntervalSet(); Assert.assertTrue(set.add(new Interval(2, 8))); set.add(new Interval(3, 5)); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testEndOverlappingUnder() { IntervalSet set = new IntervalSet(); Assert.assertTrue(set.add(new Interval(2, 8))); set.add(new Interval(1, 5)); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testEndOverlappingAbove() { IntervalSet set = new IntervalSet(); Assert.assertTrue(set.add(new Interval(2, 8))); set.add(new Interval(1, 10)); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testOverlapCustom() { IntervalSet set = new IntervalSet(); Assert.assertTrue(set.add(new Interval(1.0, 2.0))); Assert.assertTrue(set.add(new Interval(3.0, 4.0))); Assert.assertTrue(set.add(new Interval(2.0, 2.0))); set.add(new Interval(2.0, 4.0)); }