@Test
public void testToNanoCoins() {

    // String version
    assertEquals(CENT, toNanoCoins("0.01"));
    assertEquals(CENT, toNanoCoins("1E-2"));
    assertEquals(COIN.add(Utils.CENT), toNanoCoins("1.01"));
    try {
        toNanoCoins("2E-20");
        org.junit.Assert.fail("should not have accepted fractional nanocoins");
    } catch (ArithmeticException e) {
    }
    // int version
    assertEquals(CENT, toNanoCoins(0, 1));
    try {
        toNanoCoins(1, -1);
        fail();
    } catch (IllegalArgumentException e) {}
    try {
        toNanoCoins(-1, 0);
        fail();
    } catch (IllegalArgumentException e) {}
    try {
        toNanoCoins("-1");
        fail();
    } catch (ArithmeticException e) {}
}