### Question:
Range implements Comparable<Range> { public Range(int min, int max) { if (max < min) { throw new IllegalArgumentException("Range max (" + max + ") cannot be less than min (" + min + ")."); } this.min = min; this.max = max; } Range(int min, int max); @Override int compareTo(Range other); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); boolean contains(int value); long size(); public int min; public int max; }### Answer:
@Test public void testRange() { Range r; for (int i = 0; i < goodPairs.length; i++) { int[] pair = goodPairs[i]; int min = pair[0]; int max = pair[1]; r = new Range(min, max); assertEquals(min, r.min); assertEquals(max, r.max); } for (int i = 0; i < badPairs.length; i++) { int[] pair = badPairs[i]; int min = pair[0]; int max = pair[1]; try { r = new Range(min, max); Assert.fail("Didn't detect max(" + max + ") less than min(" + min + ") for Range."); } catch (IllegalArgumentException e) { } } }