Search in sources :

Example 1 with MathContext

use of android.icu.math.MathContext in project j2objc by google.

the class IntlTestDecimalFormatAPI method testJB4971.

@Test
public void testJB4971() {
    DecimalFormat decfmt = new DecimalFormat();
    MathContext resultICU;
    MathContext comp1 = new MathContext(0, MathContext.PLAIN);
    resultICU = decfmt.getMathContextICU();
    if ((comp1.getDigits() != resultICU.getDigits()) || (comp1.getForm() != resultICU.getForm()) || (comp1.getLostDigits() != resultICU.getLostDigits()) || (comp1.getRoundingMode() != resultICU.getRoundingMode())) {
        errln("ERROR: Math context 1 not equal - result: " + resultICU.toString() + " / expected: " + comp1.toString());
    }
    MathContext comp2 = new MathContext(5, MathContext.ENGINEERING);
    decfmt.setMathContextICU(comp2);
    resultICU = decfmt.getMathContextICU();
    if ((comp2.getDigits() != resultICU.getDigits()) || (comp2.getForm() != resultICU.getForm()) || (comp2.getLostDigits() != resultICU.getLostDigits()) || (comp2.getRoundingMode() != resultICU.getRoundingMode())) {
        errln("ERROR: Math context 2 not equal - result: " + resultICU.toString() + " / expected: " + comp2.toString());
    }
    java.math.MathContext result;
    java.math.MathContext comp3 = new java.math.MathContext(3, java.math.RoundingMode.DOWN);
    decfmt.setMathContext(comp3);
    result = decfmt.getMathContext();
    if ((comp3.getPrecision() != result.getPrecision()) || (comp3.getRoundingMode() != result.getRoundingMode())) {
        errln("ERROR: Math context 3 not equal - result: " + result.toString() + " / expected: " + comp3.toString());
    }
}
Also used : DecimalFormat(android.icu.text.DecimalFormat) MathContext(android.icu.math.MathContext) Test(org.junit.Test)

Aggregations

MathContext (android.icu.math.MathContext)1 DecimalFormat (android.icu.text.DecimalFormat)1 Test (org.junit.Test)1