### Question:
Coin implements Monetary, Comparable<Coin>, Serializable { public static Coin parseCoin(final String str) { try { long satoshis = new BigDecimal(str).movePointRight(SMALLEST_UNIT_EXPONENT).longValueExact(); return Coin.valueOf(satoshis); } catch (ArithmeticException e) { throw new IllegalArgumentException(e); } } private  Coin(final long satoshis); static Coin valueOf(final long satoshis); @Override int smallestUnitExponent(); @Override long getValue(); static Coin valueOf(final int coins, final int cents); static Coin parseCoin(final String str); static Coin parseCoinInexact(final String str); Coin add(final Coin value); Coin plus(final Coin value); Coin subtract(final Coin value); Coin minus(final Coin value); Coin multiply(final long factor); Coin times(final long factor); Coin times(final int factor); Coin divide(final long divisor); Coin div(final long divisor); Coin div(final int divisor); Coin[] divideAndRemainder(final long divisor); long divide(final Coin divisor); boolean isPositive(); boolean isNegative(); boolean isZero(); boolean isGreaterThan(Coin other); boolean isLessThan(Coin other); Coin shiftLeft(final int n); Coin shiftRight(final int n); @Override int signum(); Coin negate(); long longValue(); String toFriendlyString(); String toPlainString(); @Override String toString(); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(final Coin other); static final int SMALLEST_UNIT_EXPONENT; static final Coin ZERO; static final Coin COIN; static final Coin CENT; static final Coin MILLICOIN; static final Coin MICROCOIN; static final Coin SATOSHI; static final Coin FIFTY_COINS; static final Coin NEGATIVE_SATOSHI; final long value; }### Answer:
@Test public void testParseCoin() { assertEquals(CENT, parseCoin("0.01")); assertEquals(CENT, parseCoin("1E-2")); assertEquals(COIN.add(CENT), parseCoin("1.01")); assertEquals(COIN.negate(), parseCoin("-1")); try { parseCoin("2E-20"); org.junit.Assert.fail("should not have accepted fractional satoshis"); } catch (IllegalArgumentException expected) { } catch (Exception e) { org.junit.Assert.fail("should throw IllegalArgumentException"); } assertEquals(1, parseCoin("0.00000001").value); assertEquals(1, parseCoin("0.000000010").value); }
@Test(expected = IllegalArgumentException.class) public void testParseCoinOverprecise() { parseCoin("0.000000011"); }