### Question:
Comparables { public static <T extends Comparable<? super T>> T leastMagnitude( T min, T max, T zero) { if (min == null && max == null) return zero; if (min == null) return max.compareTo(zero) <= 0 ? max : zero; if (max == null) return min.compareTo(zero) >= 0 ? min : zero; if (min.compareTo(zero) > 0) return min; if (max.compareTo(zero) < 0) return max; return zero; } private  Comparables(); static Predicate<T> inRange(
        T min,
        T max); static T leastMagnitude(
        T min,
        T max,
        T zero);  }### Answer:
@Test public void leastMagnitudeUnbounded() { assertEquals(Integer.valueOf(0), Comparables.leastMagnitude(null, null, 0)); }
@Test public void leastMagnitudeNegativeMinOnly() { assertEquals(Integer.valueOf(0), Comparables.leastMagnitude(-3, null, 0)); }
@Test public void leastMagnitudePositiveMinOnly() { assertEquals(Integer.valueOf(4), Comparables.leastMagnitude(4, null, 0)); }
@Test public void leastMagnitudeNegativeMaxOnly() { assertEquals(Integer.valueOf(-2), Comparables.leastMagnitude(null, -2, 0)); }
@Test public void leastMagnitudePositiveMaxOnly() { assertEquals(Integer.valueOf(0), Comparables.leastMagnitude(null, 5, 0)); }
@Test public void leastMagnitudeBothLessThanZero() { assertEquals(Integer.valueOf(-1), Comparables.leastMagnitude(-4, -1, 0)); }
@Test public void leastMagnitudeBothGreaterThanZero() { assertEquals(Integer.valueOf(5), Comparables.leastMagnitude(5, 7, 0)); }
@Test public void leastMagnitudeStraddlingZero() { assertEquals(Integer.valueOf(0), Comparables.leastMagnitude(-2, 4, 0)); }