DiscreteInterval { public boolean contains(DiscreteInterval other) { return (min <= other.getMin() && max >= other.getMax()); } DiscreteInterval(long min, long max); long getMin(); long getMax(); long size(); DiscreteInterval plus(DiscreteInterval other); DiscreteInterval negate(); DiscreteInterval minus(DiscreteInterval other); boolean contains(DiscreteInterval other); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void doesNotContainNonOverlappingInterval() { DiscreteInterval i1 = new DiscreteInterval(1,3); assertFalse(i1.contains(new DiscreteInterval(5,6))); }
@Test public void doesNotContainPartiallyHigherInterval() { DiscreteInterval i1 = new DiscreteInterval(1,3); assertFalse(i1.contains(new DiscreteInterval(2,4))); }
@Test public void doesNotContainPartiallyLowerInterval() { DiscreteInterval i1 = new DiscreteInterval(1,3); assertFalse(i1.contains(new DiscreteInterval(0,2))); }
@Test public void containsFullySurroundedInterval() { DiscreteInterval i1 = new DiscreteInterval(1,6); assertTrue(i1.contains(new DiscreteInterval(3,4))); }
@Test public void containsIntervalWithMatchingMinimum() { DiscreteInterval i1 = new DiscreteInterval(1,6); assertTrue(i1.contains(new DiscreteInterval(1,4))); }
@Test public void containsIntervalWithMatchingMaximum() { DiscreteInterval i1 = new DiscreteInterval(1,6); assertTrue(i1.contains(new DiscreteInterval(3,6))); }
@Test public void containsItself() { DiscreteInterval i1 = new DiscreteInterval(1,6); assertTrue(i1.contains(i1)); }