]> granicus.if.org Git - icu/commitdiff
ICU-11020 Test11020(), port from Java. Rounding in Scientific Format.
authorAndy Heninger <andy.heninger@gmail.com>
Sun, 13 May 2018 01:26:42 +0000 (01:26 +0000)
committerAndy Heninger <andy.heninger@gmail.com>
Sun, 13 May 2018 01:26:42 +0000 (01:26 +0000)
X-SVN-Rev: 41372

icu4c/source/test/intltest/numfmtst.cpp
icu4c/source/test/intltest/numfmtst.h

index 2dde1cf1267cccf4a814676fbd56697790e82e38..e2f9dd97540a7d37d415fb5e74344541634c1f43 100644 (file)
@@ -682,6 +682,7 @@ void NumberFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &n
   TESTCASE_AUTO(Test12753_PatternDecimalPoint);
   TESTCASE_AUTO(Test11647_PatternCurrencySymbols);
   TESTCASE_AUTO(Test11913_BigDecimal);
+  TESTCASE_AUTO(Test11020_RoundingInScientificNotation);
   TESTCASE_AUTO_END;
 }
 
@@ -9526,4 +9527,14 @@ void NumberFormatTest::Test11913_BigDecimal() {
     assertEquals("Should format more than 309 digits", u"12,345,678", UnicodeString(result, 0, 10));
     assertEquals("Should format more than 309 digits", 534, result.length());
 }
+
+void NumberFormatTest::Test11020_RoundingInScientificNotation() {
+    UErrorCode status = U_ZERO_ERROR;
+    DecimalFormatSymbols sym(Locale::getFrance(), status);
+    DecimalFormat fmt(u"0.05E0", sym, status);
+    assertSuccess("", status);
+    UnicodeString result;
+    fmt.format(12301.2, result);
+    assertEquals("Rounding increment should be applied after magnitude scaling", u"1,25E4", result);
+}
 #endif /* #if !UCONFIG_NO_FORMATTING */
index 5f68d78a7002956cd8edd38a464c86d006c324da..57afe131e75300643bc384e05f48c7eaf3e34980 100644 (file)
@@ -245,6 +245,7 @@ class NumberFormatTest: public CalendarTimeZoneTest {
     void Test12753_PatternDecimalPoint();
     void Test11647_PatternCurrencySymbols();
     void Test11913_BigDecimal();
+    void Test11020_RoundingInScientificNotation();
 
  private:
     UBool testFormattableAsUFormattable(const char *file, int line, Formattable &f);