### Question:
MemoryRange { public static MemoryRange of(final long value) { return of(value, value); } private  MemoryRange(final long min, final long max); static MemoryRange of(final long value); static MemoryRange of(final long min, final long max); static MemoryRange empty(); MemoryRange add(final MemoryRange other); MemoryRange times(final long count); MemoryRange union(MemoryRange other); boolean isEmpty(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); final long min; final long max; }### Answer:
@Test void testFactoryMethods() { MemoryRange range; range = MemoryRange.of(42); assertEquals(42L, range.min); assertEquals(42L, range.max); range = MemoryRange.of(42, 1337); assertEquals(42L, range.min); assertEquals(1337L, range.max); }
@Test void rangeMustNotBeNegative() { try { MemoryRange.of(-42); fail(); } catch (IllegalArgumentException e) { assertEquals("min range < 0: -42", e.getMessage()); } try { MemoryRange.of(42, -1337); fail(); } catch (IllegalArgumentException e) { assertEquals("max range < 0: -1337", e.getMessage()); } }
@Test void minMustBeSmallerThanMax() { try { MemoryRange.of(1337, 42); fail(); } catch (IllegalArgumentException e) { assertEquals("max range < min: 42 < 1337", e.getMessage()); } }
@Test void equalsChecksForValueEquality() { MemoryRange range1 = MemoryRange.of(42); MemoryRange range2 = MemoryRange.of(42); MemoryRange range3 = MemoryRange.of(42, 1337); assertEquals(range1, range2); assertEquals(range2, range1); assertNotEquals(range1, range3); }