DiscreteInterval { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; DiscreteInterval other = (DiscreteInterval) obj; if (max != other.max) return false; if (min != other.min) return false; return true; } 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 intervalsWithDifferentBoundsAreNotEqual() { DiscreteInterval i1 = new DiscreteInterval(1,6); DiscreteInterval i2 = new DiscreteInterval(2,3); assertFalse(i1.equals(i2)); }
@Test public void intervalsWithDifferentMinimumsAreNotEqual() { DiscreteInterval i1 = new DiscreteInterval(1,6); DiscreteInterval i2 = new DiscreteInterval(2,6); assertFalse(i1.equals(i2)); }
@Test public void intervalsWithDifferentMaximumsAreNotEqual() { DiscreteInterval i1 = new DiscreteInterval(1,6); DiscreteInterval i2 = new DiscreteInterval(1,5); assertFalse(i1.equals(i2)); }
@Test public void intervalIsEqualToItself() { DiscreteInterval i1 = new DiscreteInterval(1,6); assertTrue(i1.equals(i1)); }
@Test public void intervalIsNotEqualToNull() { DiscreteInterval i1 = new DiscreteInterval(1,6); assertFalse(i1.equals(null)); }
@Test public void intervalIsNotEqualToNonIntervals() { DiscreteInterval i1 = new DiscreteInterval(1,6); assertFalse(i1.equals(new Object())); }