TESTCASE_AUTO(Test20961_CurrencyPluralPattern);
TESTCASE_AUTO(Test21134_ToNumberFormatter);
TESTCASE_AUTO(Test13733_StrictAndLenient);
+ TESTCASE_AUTO(Test20425_IntegerIncrement);
+ TESTCASE_AUTO(Test20425_FractionWithIntegerIncrement);
TESTCASE_AUTO(Test21232_ParseTimeout);
TESTCASE_AUTO(Test10997_FormatCurrency);
TESTCASE_AUTO_END;
}
}
+void NumberFormatTest::Test20425_IntegerIncrement() {
+ IcuTestErrorCode status(*this, "Test20425_IntegerIncrement");
+
+ DecimalFormat df("##00", status);
+ df.setRoundingIncrement(1);
+ UnicodeString actual;
+ df.format(1235.5, actual, status);
+ assertEquals("Should round to integer", u"1236", actual);
+}
+
+void NumberFormatTest::Test20425_FractionWithIntegerIncrement() {
+ IcuTestErrorCode status(*this, "Test20425_FractionWithIntegerIncrement");
+
+ DecimalFormat df("0.0", status);
+ df.setRoundingIncrement(1);
+ UnicodeString actual;
+ df.format(8.6, actual, status);
+ assertEquals("Should have a fraction digit", u"9.0", actual);
+}
+
void NumberFormatTest::Test21232_ParseTimeout() {
IcuTestErrorCode status(*this, "Test21232_ParseTimeout");
new SetMxFrAndRndIncrItem( "15 en_US DEC 1/1/3/0.02", "en_US", NumberFormat.NUMBERSTYLE, 1, 1, 3, 0.02, "#,##0.02#", 0.128, "0.12" ), // use incr
new SetMxFrAndRndIncrItem( "16 en_US DEC 1/2/2/0.02", "en_US", NumberFormat.NUMBERSTYLE, 1, 2, 2, 0.02, "#,##0.02", 0.128, "0.12" ), // use incr
new SetMxFrAndRndIncrItem( "17 en_US DEC 1/2/3/0.02", "en_US", NumberFormat.NUMBERSTYLE, 1, 2, 3, 0.02, "#,##0.02#", 0.128, "0.12" ), // use incr
- new SetMxFrAndRndIncrItem( "18 en_US DEC 1/3/3/0.02", "en_US", NumberFormat.NUMBERSTYLE, 1, 3, 3, 0.02, "#,##0.020", 0.128, "0.12" ), // use incr; expFmt != ICU4C
+ new SetMxFrAndRndIncrItem( "18 en_US DEC 1/3/3/0.02", "en_US", NumberFormat.NUMBERSTYLE, 1, 3, 3, 0.02, "#,##0.020", 0.128, "0.120" ), // use incr
new SetMxFrAndRndIncrItem( "20 en_US DEC 1/1/1/0.0075", "en_US", NumberFormat.NUMBERSTYLE, 1, 1, 1, 0.0075, "#,##0.0", 0.019, "0.0" ),
new SetMxFrAndRndIncrItem( "21 en_US DEC 1/1/2/0.0075", "en_US", NumberFormat.NUMBERSTYLE, 1, 1, 2, 0.0075, "#,##0.0075", 0.004, "0.0075" ), // use incr
double testIncr = item.roundIncr;
for (; testIncr > ((int)testIncr); testIncr *= 10.0, fracForRoundIncr++);
}
+ if (fracForRoundIncr < item.minFrac) {
+ fracForRoundIncr = item.minFrac;
+ }
int minInt = df.getMinimumIntegerDigits();
if (minInt != item.minInt) {
}
}
+ @Test
+ public void Test20425_IntegerIncrement() {
+ DecimalFormat df = new DecimalFormat("##00");
+ df.setRoundingIncrement(1);
+ String actual = df.format(1235.5);
+ assertEquals("Should round to integer", "1236", actual);
+ }
+
+ @Test
+ public void Test20425_FractionWithIntegerIncrement() {
+ DecimalFormat df = new DecimalFormat("0.0");
+ df.setRoundingIncrement(1);
+ String actual = df.format(8.6);
+ assertEquals("Should have a fraction digit", "9.0", actual);
+ }
+
@Test
public void Test21232_ParseTimeout() throws ParseException {
DecimalFormat df = new DecimalFormat();