297298299300301302303304305306307
public void testRound() { FixedDecimalNumber fda = new FixedDecimalNumber("1"); try { fda.round(9); // too big but not an error } catch (Exception e) { fail(e.getMessage()); } assertEquals("1", fda.get());
305306307308309310311312313314315
} assertEquals("1", fda.get()); fda = new FixedDecimalNumber("1"); try { fda.round(-9); fail("should throw exception"); } catch (Exception e) { }
313314315316317318319320321322323
} fda = new FixedDecimalNumber("1.0"); try { fda.round(9); // too big but not an error } catch (Exception e) { fail(e.getMessage()); } assertEquals("1.0", fda.get());
321322323324325326327328329330331
} assertEquals("1.0", fda.get()); fda = new FixedDecimalNumber("1.0"); try { fda.round(0); } catch (Exception e) { fail(e.getMessage()); } assertEquals("1", fda.get());
329330331332333334335336337338339
} assertEquals("1", fda.get()); fda = new FixedDecimalNumber("1.0"); try { fda.round(9); // too big but not an error } catch (Exception e) { fail(e.getMessage()); } assertEquals("1.0", fda.get());
337338339340341342343344345346347
} assertEquals("1.0", fda.get()); fda = new FixedDecimalNumber("1.00000000000000"); try { fda.round(0); } catch (Exception e) { fail(e.getMessage()); } assertEquals("1", fda.get());
345346347348349350351352353354355
} assertEquals("1", fda.get()); fda = new FixedDecimalNumber("1.09"); try { fda.round(1); } catch (Exception e) { fail(e.getMessage()); } assertEquals("1.1", fda.get());
353354355356357358359360361362363
} assertEquals("1.1", fda.get()); fda = new FixedDecimalNumber("1.09"); try { fda.round(2); } catch (Exception e) { fail(e.getMessage()); } assertEquals("1.09", fda.get());