@@ -0,0 +1,2149 @@
+package de.jpaw.fixedpoint.tests;%0A%0Aimport java.math.BigDecimal;%0Aimport java.math.RoundingMode;%0A%0Aimport org.junit.jupiter.api.Assertions;%0Aimport org.junit.jupiter.api.Test;%0A%0Aimport de.jpaw.fixedpoint.types.MicroUnits;%0A%0Apublic class TestRounding %7B%0A%0A    @Test%0A    public void testRounding() throws Exception %7B%0A        MicroUnits mpi = MicroUnits.valueOf(Math.PI);%0A        BigDecimal bdpi = BigDecimal.valueOf(Math.PI).setScale(6, RoundingMode.HALF_EVEN);%0A        assertSame(mpi, bdpi, %22Original value of PI%22);%0A%0A        MicroUnits me = MicroUnits.valueOf(Math.E);%0A        BigDecimal bde = BigDecimal.valueOf(Math.E).setScale(6, RoundingMode.HALF_EVEN);%0A        assertSame(me, bde, %22Original value of E%22);%0A%0A        MicroUnits mipi = mpi.negate();%0A        BigDecimal bdmpi = bdpi.negate();%0A        assertSame(mipi, bdmpi, %22Negated value of PI%22);%0A%0A        for (int digits = 5; digits %3E= 0; --digits) %7B%0A            for (RoundingMode rm : RoundingMode.values()) %7B%0A                if (rm != RoundingMode.UNNECESSARY) %7B%0A                    final String what = %22Rounded to %22 + digits + %22 digits with mode %22 + rm.name();%0A                    assertSame(mpi.round(digits, rm), bdpi.setScale(digits, rm), what);%0A                    assertSame(mipi.round(digits, rm), bdmpi.setScale(digits, rm), what + %22 (negative)%22);%0A%0A                    // now also try the multiplication%0A                    assertSame(mpi.round(digits, rm).multiply(me, rm), bdpi.setScale(digits, rm).multiply(bde).setScale(6, rm), what + %22 (times e)%22);%0A                    assertSame(mipi.round(digits, rm).multiply(me, rm), bdmpi.setScale(digits, rm).multiply(bde).setScale(6, rm), what + %22 (times e, negative)%22);%0A                %7D%0A            %7D%0A        %7D%0A    %7D%0A%0A    // assert that the fixed point number and the BigDecimal have the same value  %0A    void assertSame(MicroUnits m, BigDecimal bd, String where) %7B%0A        BigDecimal actual = m.toBigDecimal();%0A        boolean result = bd.compareTo(actual) == 0;%0A        if (!result) %7B%0A            System.out.println(%22Mismatch for %22 + where + %22: expected %22 + bd + %22, but got %22 + m);%0A        %7D%0A        Assertions.assertTrue(result, where);%0A    %7D%0A%7D%0A

add tests for rounding and multiplication