### Question:
ShortDuration implements Comparable<ShortDuration> { public static ShortDuration valueOf(String s) { if ("0".equals(s)) { return ZERO; } Matcher matcher = PATTERN.matcher(s); checkArgument(matcher.matches(), "Invalid ShortDuration: %s", s); BigDecimal value = new BigDecimal(matcher.group(1)); String abbrev = matcher.group(2); TimeUnit unit = ABBREV_TO_UNIT.get(abbrev); checkArgument(unit != null, "Unrecognized time unit: %s", abbrev); return of(value, unit); } ShortDuration(long picos); static ShortDuration of(long duration, TimeUnit unit); static ShortDuration of(BigDecimal duration, TimeUnit unit); static ShortDuration valueOf(String s); static ShortDuration zero(); long toPicos(); long to(TimeUnit unit); abstract long to(TimeUnit unit, RoundingMode roundingMode); abstract ShortDuration plus(ShortDuration addend); abstract ShortDuration minus(ShortDuration subtrahend); abstract ShortDuration times(long multiplicand); abstract ShortDuration times(BigDecimal multiplicand, RoundingMode roundingMode); abstract ShortDuration dividedBy(long divisor, RoundingMode roundingMode); abstract ShortDuration dividedBy(BigDecimal divisor, RoundingMode roundingMode);  }### Answer:
@Test public void valueOf() { assertEquals(ShortDuration.zero(), ShortDuration.valueOf("0")); testIt(0, "0ns", "0s"); testIt(0, "0 ns", "0s"); testIt(0, "0nanos", "0s"); testIt(0, "0nanoseconds", "0s"); testIt(0, "0 ms", "0s"); testIt(0, "0us", "0s"); testIt(0, "1e-12 ms", "0s"); testIt(1, "0.501 ns", "0.501ns"); testIt(1000, "1 \u03bcs", "1\u03bcs"); }
@Test public void tooLongForALong() { try { ShortDuration.valueOf("106751.99116730064592 days"); fail(); } catch (ArithmeticException expected) { } }