]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/intltest/numrgts.cpp
ICU-66108.tar.gz
[apple/icu.git] / icuSources / test / intltest / numrgts.cpp
index 5e449279d22a3d419feec8dda50bc9f844f265cf..7bdb5f86ea87e10f416fcef19620aba3f4c0f6c7 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "numrgts.h"
 
+#include <cmath>   // std::signbit
 #include <float.h> // DBL_MIN, DBL_MAX
 #include <stdio.h>
 
@@ -22,6 +23,7 @@
 #include "unicode/datefmt.h"
 #include "unicode/ucurr.h"
 #include "cmemory.h"
+#include "cstr.h"
 #include "putilimp.h"
 #include "uassert.h"
 
@@ -76,7 +78,7 @@ public:
     {
         NumberFormat::parse(text, result, status);
     }
-    virtual Format* clone() const 
+    virtual MyNumberFormatTest* clone() const 
     { return NULL; }
 
     virtual UnicodeString& format(int32_t, 
@@ -547,8 +549,8 @@ void NumberFormatRegressionTest::Test4086575(void)
     // nbsp = \u00a0
     //nf->applyLocalizedPattern("#\u00a0###,00;(#\u00a0###,00)");
     UChar patChars[] = {
-             0x23, 0x00a0, 0x23, 0x23, 0x23, 0x2c, 0x30, 0x30, 0x3b, 
-        0x28, 0x23, 0x00a0, 0x23, 0x23, 0x23, 0x2c, 0x30, 0x30, 0x29
+             0x23, 0x202f, 0x23, 0x23, 0x23, 0x2c, 0x30, 0x30, 0x3b, 
+        0x28, 0x23, 0x202f, 0x23, 0x23, 0x23, 0x2c, 0x30, 0x30, 0x29
     };
     UnicodeString pat(patChars, 19, 19);
     nf->applyLocalizedPattern(pat, status);
@@ -559,7 +561,7 @@ void NumberFormatRegressionTest::Test4086575(void)
     buffer = nf->format((int32_t)1234, buffer, pos);
     //if (buffer != UnicodeString("1\u00a0234,00"))
     UChar c[] = {
-        0x31, 0x00a0, 0x32, 0x33, 0x34, 0x2c, 0x30, 0x30
+        0x31, 0x202f, 0x32, 0x33, 0x34, 0x2c, 0x30, 0x30
     };
     UnicodeString cc(c, 8, 8);
     if (buffer != cc)
@@ -568,7 +570,7 @@ void NumberFormatRegressionTest::Test4086575(void)
     buffer.remove();
     buffer = nf->format((int32_t)-1234, buffer, pos);
     UChar c1[] = {
-        0x28, 0x31, 0x00a0, 0x32, 0x33, 0x34, 0x2c, 0x30, 0x30, 0x29
+        0x28, 0x31, 0x202f, 0x32, 0x33, 0x34, 0x2c, 0x30, 0x30, 0x29
     };
     UnicodeString cc1(c1, 10, 10);
     if (buffer != cc1)
@@ -806,29 +808,29 @@ void NumberFormatRegressionTest::Test4092480 (void)
         dfFoo->applyPattern("0000;-000", status);
         failure(status, "dfFoo->applyPattern");
         UnicodeString temp;
-        if (dfFoo->toPattern(temp) != UnicodeString("#0000"))
-            errln("dfFoo.toPattern : " + dfFoo->toPattern(temp));
+        if (dfFoo->toPattern(temp) != UnicodeString("0000"))
+            errln("ERROR: dfFoo.toPattern : " + dfFoo->toPattern(temp));
         FieldPosition pos(FieldPosition::DONT_CARE);
         logln(dfFoo->format((int32_t)42, temp, pos));
         logln(dfFoo->format((int32_t)-42, temp, pos));
         dfFoo->applyPattern("000;-000", status);
         failure(status, "dfFoo->applyPattern");
-        if (dfFoo->toPattern(temp) != UnicodeString("#000"))
-            errln("dfFoo.toPattern : " + dfFoo->toPattern(temp));
+        if (dfFoo->toPattern(temp) != UnicodeString("000"))
+            errln("ERROR: dfFoo.toPattern : " + dfFoo->toPattern(temp));
         logln(dfFoo->format((int32_t)42,temp, pos));
         logln(dfFoo->format((int32_t)-42, temp, pos));
 
         dfFoo->applyPattern("000;-0000", status);
         failure(status, "dfFoo->applyPattern");
-        if (dfFoo->toPattern(temp) != UnicodeString("#000"))
-            errln("dfFoo.toPattern : " + dfFoo->toPattern(temp));
+        if (dfFoo->toPattern(temp) != UnicodeString("000"))
+            errln("ERROR: dfFoo.toPattern : " + dfFoo->toPattern(temp));
         logln(dfFoo->format((int32_t)42, temp, pos));
         logln(dfFoo->format((int32_t)-42, temp, pos));
 
         dfFoo->applyPattern("0000;-000", status);
         failure(status, "dfFoo->applyPattern");
-        if (dfFoo->toPattern(temp) != UnicodeString("#0000"))
-            errln("dfFoo.toPattern : " + dfFoo->toPattern(temp));
+        if (dfFoo->toPattern(temp) != UnicodeString("0000"))
+            errln("ERROR: dfFoo.toPattern : " + dfFoo->toPattern(temp));
         logln(dfFoo->format((int32_t)42, temp, pos));
         logln(dfFoo->format((int32_t)-42, temp, pos));
     /*} catch (Exception foo) {
@@ -848,15 +850,15 @@ void NumberFormatRegressionTest::Test4092480 (void)
 void NumberFormatRegressionTest::Test4087244 (void) {
     UErrorCode status = U_ZERO_ERROR;
     char loc[256] = {0};
-    uloc_canonicalize("pt_PT_PREEURO", loc, 256, &status);
-    Locale *de = new Locale(loc);
-    NumberFormat *nf = NumberFormat::createCurrencyInstance(*de, status);
+
+    uloc_canonicalize("pt_PT@currency=PTE", loc, 256, &status);
+    Locale de(loc);
+    LocalPointer<NumberFormat> nf(NumberFormat::createCurrencyInstance(de, status));
     if(U_FAILURE(status)) {
-      dataerrln("Error creating DecimalFormat: %s", u_errorName(status));
-      delete nf;
-      return;
+        dataerrln("Error creating DecimalFormat: %s", u_errorName(status));
+        return;
     }
-    DecimalFormat *df = dynamic_cast<DecimalFormat *>(nf);
+    DecimalFormat *df = dynamic_cast<DecimalFormat *>(nf.getAlias());
     if(df == NULL) {
         errln("expected DecimalFormat!");
         return;
@@ -885,8 +887,6 @@ void NumberFormatRegressionTest::Test4087244 (void) {
               monStr +
               "\" and not \"" + decStr + '"');
     }
-    delete de;
-    delete nf;
 }
 /* @bug 4070798
  * Number format data rounding errors for locale FR
@@ -897,18 +897,18 @@ void NumberFormatRegressionTest::Test4070798 (void)
     UnicodeString tempString;
     
     /* User error :
-    String expectedDefault = "-5\u00a0789,987";
-    String expectedCurrency = "5\u00a0789,98\u00a0F";
-    String expectedPercent = "-578\u00a0998%";
+    String expectedDefault = "-5\u202f789,987";
+    String expectedCurrency = "5\u202f789,98\u00a0F";
+    String expectedPercent = "-578\u202f998%";
     */
     UChar chars1 [] = {
-        0x2d, 0x35, 0x00a0, 0x37, 0x38, 0x39, 0x2c, 0x39, 0x38, 0x38
+        0x2d, 0x35, 0x202f, 0x37, 0x38, 0x39, 0x2c, 0x39, 0x38, 0x38
     };
     UChar chars2 [] = {
-        0x35, 0x00a0, 0x37, 0x38, 0x39, 0x2c, 0x39, 0x39, 0x00a0, 0x46
+        0x35, 0x202f, 0x37, 0x38, 0x39, 0x2c, 0x39, 0x39, 0x00a0, 0x46
     };
     UChar chars3 [] = {
-        0x2d, 0x35, 0x37, 0x38, 0x00a0, 0x39, 0x39, 0x39, 0x00a0, 0x25
+        0x2d, 0x35, 0x37, 0x38, 0x202f, 0x39, 0x39, 0x39, 0x00a0, 0x25
     };
     UnicodeString expectedDefault(chars1, 10, 10);
     UnicodeString expectedCurrency(chars2, 10, 10);
@@ -916,7 +916,7 @@ void NumberFormatRegressionTest::Test4070798 (void)
 
     UErrorCode status = U_ZERO_ERROR;
     char loc[256]={0};
-    int len = uloc_canonicalize("fr_FR_PREEURO", loc, 256, &status);
+    int len = uloc_canonicalize("fr_FR@currency=FRF", loc, 256, &status);
     (void)len;  // Suppress set but not used warning.
     formatter = NumberFormat::createInstance(Locale(loc), status);
     if(U_FAILURE(status)) {
@@ -935,7 +935,7 @@ void NumberFormatRegressionTest::Test4070798 (void)
         " Received " + tempString );
     }
     delete formatter;
-    len = uloc_canonicalize("fr_FR_PREEURO", loc, 256, &status);
+    len = uloc_canonicalize("fr_FR@currency=FRF", loc, 256, &status);
     formatter = NumberFormat::createCurrencyInstance(loc, status);
     failure(status, "NumberFormat::createCurrencyInstance", loc);
     tempString.remove();
@@ -950,7 +950,7 @@ void NumberFormatRegressionTest::Test4070798 (void)
     }
     delete formatter;
    
-    uloc_canonicalize("fr_FR_PREEURO", loc, 256, &status);
+    uloc_canonicalize("fr_FR@currency=FRF", loc, 256, &status);
     formatter = NumberFormat::createPercentInstance(Locale(loc), status);
     failure(status, "NumberFormat::createPercentInstance", loc);
     tempString.remove();
@@ -996,7 +996,7 @@ void NumberFormatRegressionTest::Test4071005 (void)
     if (failure(status, "NumberFormat::createInstance", Locale::getCanadaFrench(), TRUE)){
         delete formatter;
         return;
-    };
+    }
     tempString = formatter->format (-5789.9876, tempString);
 
     if (tempString == expectedDefault) {
@@ -1059,7 +1059,7 @@ void NumberFormatRegressionTest::Test4071014 (void)
 
     UErrorCode status = U_ZERO_ERROR;
     char loc[256]={0};
-    uloc_canonicalize("de_DE_PREEURO", loc, 256, &status);
+    uloc_canonicalize("de_DE@currency=DEM", loc, 256, &status);
     formatter = NumberFormat::createInstance(Locale(loc), status);
     if (failure(status, "NumberFormat::createInstance", loc, TRUE)){
         delete formatter;
@@ -1076,7 +1076,7 @@ void NumberFormatRegressionTest::Test4071014 (void)
         " Received " + tempString );
     }
     delete formatter;
-    uloc_canonicalize("de_DE_PREEURO", loc, 256, &status);
+    uloc_canonicalize("de_DE@currency=DEM", loc, 256, &status);
     formatter = NumberFormat::createCurrencyInstance(Locale(loc), status);
     failure(status, "NumberFormat::createCurrencyInstance", loc);
     tempString.remove();
@@ -1125,12 +1125,12 @@ void NumberFormatRegressionTest::Test4071859 (void)
 
     UErrorCode status = U_ZERO_ERROR;
     char loc[256]={0};
-    uloc_canonicalize("it_IT_PREEURO", loc, 256, &status);
+    uloc_canonicalize("it_IT@currency=ITL", loc, 256, &status);
     formatter = NumberFormat::createInstance(Locale(loc), status);
     if (failure(status, "NumberFormat::createNumberInstance", TRUE)){
         delete formatter;
         return;
-    };
+    }
     tempString = formatter->format (-5789.9876, tempString);
 
     if (tempString == expectedDefault) {
@@ -1141,7 +1141,7 @@ void NumberFormatRegressionTest::Test4071859 (void)
         " Received " + tempString );
     }
     delete formatter;
-    uloc_canonicalize("it_IT_PREEURO", loc, 256, &status);
+    uloc_canonicalize("it_IT@currency=ITL", loc, 256, &status);
     formatter = NumberFormat::createCurrencyInstance(Locale(loc), status);
     failure(status, "NumberFormat::createCurrencyInstance");
     tempString.remove();
@@ -1155,7 +1155,7 @@ void NumberFormatRegressionTest::Test4071859 (void)
         " Received " + tempString );
     }
     delete formatter;
-    uloc_canonicalize("it_IT_PREEURO", loc, 256, &status);
+    uloc_canonicalize("it_IT@currency=ITL", loc, 256, &status);
     formatter = NumberFormat::createPercentInstance(Locale(loc), status);
     failure(status, "NumberFormat::createPercentInstance");
     tempString.remove();
@@ -1177,30 +1177,28 @@ void NumberFormatRegressionTest::Test4071859 (void)
 void NumberFormatRegressionTest::Test4093610(void)
 {
     UErrorCode status = U_ZERO_ERROR;
-    DecimalFormat *df = new DecimalFormat("#0.#", status);
+    DecimalFormat df("#0.#", status);
     if (!failure(status, "new DecimalFormat")) {
         UnicodeString s("12.4");
-        roundingTest(df, 12.35, s);
-        roundingTest(df, 12.45, s);
+        roundingTest(&df, 12.35, s);
+        roundingTest(&df, 12.45, s);
         s = "12.5";
-        roundingTest(df, 12.452,s);
+        roundingTest(&df, 12.452,s);
         s = "12.6";
-        roundingTest(df, 12.55, s);
-        roundingTest(df, 12.65, s);
+        roundingTest(&df, 12.55, s);
+        roundingTest(&df, 12.65, s);
         s = "12.7";
-        roundingTest(df, 12.652,s);
+        roundingTest(&df, 12.652,s);
         s = "12.8";
-        roundingTest(df, 12.75, s);
-        roundingTest(df, 12.752,s);
-        roundingTest(df, 12.85, s);
+        roundingTest(&df, 12.75, s);
+        roundingTest(&df, 12.752,s);
+        roundingTest(&df, 12.85, s);
         s = "12.9";
-        roundingTest(df, 12.852,s);
+        roundingTest(&df, 12.852,s);
         s = "13";
-        roundingTest(df, 12.95, s);
-        roundingTest(df, 12.952,s);
+        roundingTest(&df, 12.95, s);
+        roundingTest(&df, 12.952,s);
     }
-
-    delete df;
 }
 
 void NumberFormatRegressionTest::roundingTest(DecimalFormat *df, double x, UnicodeString& expected)
@@ -1209,8 +1207,9 @@ void NumberFormatRegressionTest::roundingTest(DecimalFormat *df, double x, Unico
     FieldPosition pos(FieldPosition::DONT_CARE);
     out = df->format(x, out, pos);
     logln(UnicodeString("") + x + " formats with 1 fractional digits to " + out);
-    if (out != expected) 
-        errln("FAIL: Expected " + expected);
+    if (out != expected) {
+        dataerrln("FAIL: Expected '%s'; got '%s'", CStr(expected)(), CStr(out)());
+    }
 }
 /* @bug 4098741
  * Tests the setMaximumFractionDigits limit.
@@ -1691,6 +1690,12 @@ void NumberFormatRegressionTest::Test4122840(void)
         // Create a DecimalFormat using the pattern we got and format a number
         DecimalFormatSymbols *symbols = new DecimalFormatSymbols(locales[i], status);
         failure(status, "new DecimalFormatSymbols");
+
+        // Disable currency spacing for the purposes of this test.
+        // To do this, set the spacing insert to the empty string both before and after the symbol.
+        symbols->setPatternForCurrencySpacing(UNUM_CURRENCY_INSERT, FALSE, u"");
+        symbols->setPatternForCurrencySpacing(UNUM_CURRENCY_INSERT, TRUE, u"");
+
         DecimalFormat *fmt1 = new DecimalFormat(pattern, *symbols, status);
         failure(status, "new DecimalFormat");
         
@@ -1886,9 +1891,11 @@ void NumberFormatRegressionTest::Test4134300(void) {
 void NumberFormatRegressionTest::Test4140009(void) 
 {
     UErrorCode status = U_ZERO_ERROR;
-    DecimalFormatSymbols *syms = new DecimalFormatSymbols(Locale::getEnglish(), status);
-    failure(status, "new DecimalFormatSymbols");
-    DecimalFormat *f = new DecimalFormat(UnicodeString(""), syms, status);
+    LocalPointer<DecimalFormatSymbols> syms(new DecimalFormatSymbols(Locale::getEnglish(), status), status);
+    if (failure(status, "new DecimalFormatSymbols")) {
+        return;
+    }
+    DecimalFormat *f = new DecimalFormat(UnicodeString(u""), syms.orphan(), status);
     if (!failure(status, "new DecimalFormat")) {
         UnicodeString s;
         FieldPosition pos(FieldPosition::DONT_CARE);
@@ -1933,7 +1940,7 @@ void NumberFormatRegressionTest::Test4145457() {
     if (failure(status, "NumberFormat::createInstance", TRUE)){
         delete nff;
         return;
-    };
+    }
     DecimalFormat *nf = dynamic_cast<DecimalFormat *>(nff);
     if(nf == NULL) {
         errln("DecimalFormat needed to continue");
@@ -2003,6 +2010,8 @@ void NumberFormatRegressionTest::Test4145457() {
  * DecimalFormat.applyPattern() sets minimum integer digits incorrectly.
  * CANNOT REPRODUCE
  * This bug is a duplicate of 4139344, which is a duplicate of 4134300
+ *
+ * ICU 62: minInt is always at least one, and the getter should reflect that!
  */
 void NumberFormatRegressionTest::Test4147295(void) 
 {
@@ -2013,7 +2022,7 @@ void NumberFormatRegressionTest::Test4147295(void)
     sdf->applyPattern(pattern, status);
     if (!failure(status, "sdf->applyPattern")) {
         int minIntDig = sdf->getMinimumIntegerDigits();
-        if (minIntDig != 0) {
+        if (minIntDig != 1) {
             errln("Test failed");
             errln(UnicodeString(" Minimum integer digits : ") + minIntDig);
             UnicodeString temp;
@@ -2132,8 +2141,9 @@ NumberFormatRegressionTest::Test4162852(void)
 {
     UErrorCode status = U_ZERO_ERROR;
     for(int32_t i=0; i < 2; ++i) {
-        NumberFormat *f = (i == 0) ? NumberFormat::createInstance(status)
-            : NumberFormat::createPercentInstance(status);
+        LocalPointer<NumberFormat> f(
+            ((i == 0) ? NumberFormat::createInstance(status) : NumberFormat::createPercentInstance(status)),
+            status);
         if(U_FAILURE(status)) {
             dataerrln("Couldn't create number format - %s", u_errorName(status));
             return;
@@ -2144,20 +2154,19 @@ NumberFormatRegressionTest::Test4162852(void)
         f->format(d, s);
         Formattable n;
         f->parse(s, n, status);
-        if(U_FAILURE(status))
+        if(U_FAILURE(status)) {
             errln("Couldn't parse!");
+            return;
+        }
         double e = n.getDouble();
-        logln(UnicodeString("") +
-              d + " -> " +
-              '"' + s + '"' + " -> " + e);
+        logln("%f -> \"%s\" -> %f", d, CStr(s)(), e);
 #if (U_PLATFORM == U_PF_OS390 && !defined(IEEE_754)) || U_PLATFORM == U_PF_OS400
         if (e != 0.0) {
 #else
-        if (e != 0.0 || 1.0/e > 0.0) {
+        if (e != 0.0 || (std::signbit(e) == false)) {
 #endif
-            logln("Failed to parse negative zero");
+            errln("Failed to parse negative zero");
         }
-        delete f;
     }
 }
 
@@ -2174,7 +2183,7 @@ void NumberFormatRegressionTest::Test4167494(void) {
     if (failure(status, "NumberFormat::createInstance", TRUE)){
         delete fmt;
         return;
-    };
+    }
 
     double a = DBL_MAX * 0.99; // DBL_MAX itself overflows to +Inf
     UnicodeString s;
@@ -2205,26 +2214,31 @@ void NumberFormatRegressionTest::Test4167494(void) {
  * DecimalFormat.parse() fails when ParseIntegerOnly set to true
  */
 void NumberFormatRegressionTest::Test4170798(void) {
-    UErrorCode status = U_ZERO_ERROR;
-    NumberFormat *nf = NumberFormat::createInstance(Locale::getUS(), status);
-    if (failure(status, "NumberFormat::createInstance", TRUE)){
-        delete nf;
-        return;
-    };
-    DecimalFormat *df = dynamic_cast<DecimalFormat *>(nf);
-    if(df == NULL) {
-        errln("DecimalFormat needed to continue");
+    IcuTestErrorCode status(*this, "Test4170798");
+    LocalPointer<DecimalFormat> df(dynamic_cast<DecimalFormat*>(
+            NumberFormat::createInstance(Locale::getUS(), status)), status);
+    if (!assertSuccess("", status, true, __FILE__, __LINE__)) {
         return;
     }
+    {
+        Formattable n;
+        ParsePosition pos(0);
+        df->parse("-0.0", n, pos);
+        if (n.getType() != Formattable::kDouble
+            || n.getDouble() != -0.0) {
+            errln(UnicodeString("FAIL: default parse(\"-0.0\") returns ") + toString(n));
+        }
+    }
     df->setParseIntegerOnly(TRUE);
-    Formattable n;
-    ParsePosition pos(0);
-    df->parse("-0.0", n, pos);
-    if (n.getType() != Formattable::kLong
-        || n.getLong() != 0) {
-        errln(UnicodeString("FAIL: parse(\"-0.0\") returns ") + toString(n));
+    {
+        Formattable n;
+        ParsePosition pos(0);
+        df->parse("-0.0", n, pos);
+        if (n.getType() != Formattable::kLong
+            || n.getLong() != 0) {
+            errln(UnicodeString("FAIL: integer parse(\"-0.0\") returns ") + toString(n));
+        }
     }
-    delete nf;
 }
 
 /**
@@ -2233,15 +2247,15 @@ void NumberFormatRegressionTest::Test4170798(void) {
  */
 void NumberFormatRegressionTest::Test4176114(void) {
     const char* DATA[] = {
-        "00", "#00",
-        "000", "#000", // No grouping
-        "#000", "#000", // No grouping
+        "00", "00",
+        "000", "000", // No grouping
+        "#000", "000", // No grouping
         "#,##0", "#,##0",
         "#,000", "#,000",
-        "0,000", "#0,000",
-        "00,000", "#00,000",
-        "000,000", "#,000,000",
-        "0,000,000,000,000.0000", "#0,000,000,000,000.0000", // Reported
+        "0,000", "0,000",
+        "00,000", "00,000",
+        "000,000", "000,000",
+        "0,000,000,000,000.0000", "0,000,000,000,000.0000", // Reported
     };
     int DATA_length = UPRV_LENGTHOF(DATA);
     UErrorCode status = U_ZERO_ERROR;
@@ -2372,9 +2386,9 @@ void NumberFormatRegressionTest::Test4212072(void) {
     sym.setSymbol(DecimalFormatSymbols::kCurrencySymbol, "usd");
     fmt.setDecimalFormatSymbols(sym);
     s.remove();
-    if (fmt.format(12.5, s, pos) != UnicodeString("usd12.50")) {
+    if (fmt.format(12.5, s, pos) != UnicodeString(u"usd\u00A012.50")) {
         errln(UnicodeString("FAIL: 12.5 x (currency=usd) -> ") + s +
-              ", exp usd12.50");
+              u", exp usd\u00A012.50");
     }
     s.remove();
     if (fmt.getPositivePrefix(s) != UnicodeString("usd")) {
@@ -2388,9 +2402,9 @@ void NumberFormatRegressionTest::Test4212072(void) {
     sym.setSymbol(DecimalFormatSymbols::kIntlCurrencySymbol, "DOL");
     fmt.setDecimalFormatSymbols(sym);
     s.remove();
-    if (fmt.format(12.5, s, pos) != UnicodeString("DOL12.50")) {
+    if (fmt.format(12.5, s, pos) != UnicodeString(u"DOL\u00A012.50")) {
         errln(UnicodeString("FAIL: 12.5 x (intlcurrency=DOL) -> ") + s +
-              ", exp DOL12.50");
+              u", exp DOL\u00A012.50");
     }
     s.remove();
     if (fmt.getPositivePrefix(s) != UnicodeString("DOL")) {
@@ -2499,7 +2513,7 @@ void NumberFormatRegressionTest::Test4216742(void) {
     if (failure(status, "createInstance", Locale::getUS(), TRUE)){
         delete fmt;
         return;
-    };
+    }
     int32_t DATA[] = { INT32_MIN, INT32_MAX, -100000000, 100000000 };
     int DATA_length = UPRV_LENGTHOF(DATA);
     for (int i=0; i<DATA_length; ++i) {
@@ -2541,7 +2555,7 @@ void NumberFormatRegressionTest::Test4217661(void) {
     if (failure(status, "createInstance", Locale::getUS(), TRUE)){
         delete fmt;
         return;
-    };
+    }
     fmt->setMaximumFractionDigits(2);
     for (int i=0; i<D_length; i++) {
         UnicodeString s;
@@ -2562,7 +2576,7 @@ void NumberFormatRegressionTest::Test4161100(void) {
     if (failure(status, "createInstance", Locale::getUS(), TRUE)){
         delete nf;
         return;
-    };
+    }
     nf->setMinimumFractionDigits(1);
     nf->setMaximumFractionDigits(1);
     double a = -0.09;
@@ -2665,18 +2679,18 @@ void NumberFormatRegressionTest::TestJ691(void) {
     Locale loc("fr", "CH");
 
     // set up the input date string & expected output
-    UnicodeString udt("11.10.2000", "");
-    UnicodeString exp("11.10.00", "");
+    UnicodeString udt(u"11.10.2000");
+    UnicodeString exp(u"11.10.00");
 
     // create a Calendar for this locale
-    Calendar *cal = Calendar::createInstance(loc, status);
+    LocalPointer<Calendar> cal(Calendar::createInstance(loc, status));
     if (U_FAILURE(status)) {
         dataerrln("FAIL: Calendar::createInstance() returned " + (UnicodeString)u_errorName(status));
         return;
     }
 
     // create a NumberFormat for this locale
-    NumberFormat *nf = NumberFormat::createInstance(loc, status);
+    LocalPointer<NumberFormat> nf(NumberFormat::createInstance(loc, status));
     if (U_FAILURE(status)) {
         dataerrln("FAIL: NumberFormat::createInstance() returned " + (UnicodeString)u_errorName(status));
         return;
@@ -2684,16 +2698,19 @@ void NumberFormatRegressionTest::TestJ691(void) {
 
     // *** Here's the key: We don't want to have to do THIS:
     // nf->setParseIntegerOnly(TRUE);
+    // or this (with changes to fr_CH per cldrbug:9370):
+    // nf->setGroupingUsed(FALSE);
+    // so they are done in DateFormat::adoptNumberFormat
 
     // create the DateFormat
-    DateFormat *df = DateFormat::createDateInstance(DateFormat::kShort, loc);
+    LocalPointer<DateFormat> df(DateFormat::createDateInstance(DateFormat::kShort, loc));
     if (U_FAILURE(status)) {
         errln("FAIL: DateFormat::createInstance() returned " + (UnicodeString)u_errorName(status));
         return;
     }
 
-    df->adoptCalendar(cal);
-    df->adoptNumberFormat(nf);
+    df->adoptCalendar(cal.orphan());
+    df->adoptNumberFormat(nf.orphan());
 
     // set parsing to lenient & parse
     df->setLenient(TRUE);
@@ -2706,8 +2723,6 @@ void NumberFormatRegressionTest::TestJ691(void) {
     if (outString != exp) {
         errln("FAIL: " + udt + " => " + outString);
     }
-
-    delete df;
 }
 
 //---------------------------------------------------------------------------
@@ -2715,27 +2730,28 @@ void NumberFormatRegressionTest::TestJ691(void) {
 //   Error Checking / Reporting macros
 //
 //---------------------------------------------------------------------------
-#define TEST_CHECK_STATUS(status) { \
+#define TEST_CHECK_STATUS(status) UPRV_BLOCK_MACRO_BEGIN { \
     if (U_FAILURE(status)) { \
         if (status == U_MISSING_RESOURCE_ERROR) { \
             dataerrln("File %s, Line %d: status=%s", __FILE__, __LINE__, u_errorName(status)); \
         } else { \
             errln("File %s, Line %d: status=%s", __FILE__, __LINE__, u_errorName(status)); \
         } return; \
-    }}
+    } \
+} UPRV_BLOCK_MACRO_END
 
-#define TEST_ASSERT(expr) \
+#define TEST_ASSERT(expr) UPRV_BLOCK_MACRO_BEGIN { \
     if ((expr)==FALSE) {\
         errln("File %s, line %d: Assertion Failed: " #expr "\n", __FILE__, __LINE__);\
-    }
-#define TEST_ASSERT_EQUALS(x,y)                  \
-    {                                                                     \
+    } \
+} UPRV_BLOCK_MACRO_END
+#define TEST_ASSERT_EQUALS(x,y) UPRV_BLOCK_MACRO_BEGIN { \
       char _msg[1000]; \
-      int32_t len = sprintf (_msg,"File %s, line %d: Assertion Failed: " #x "==" #y "\n", __FILE__, __LINE__); \
+      int32_t len = sprintf (_msg,"File %s, line %d: " #x "==" #y, __FILE__, __LINE__); \
       (void)len;                                                         \
       U_ASSERT(len < (int32_t) sizeof(_msg));                            \
       assertEquals((const char*) _msg, x,y);                             \
-    }
+} UPRV_BLOCK_MACRO_END
 
 
 // Ticket 8199:  Parse failure for numbers in the range of 1E10 - 1E18
@@ -2756,10 +2772,10 @@ void NumberFormatRegressionTest::Test8199(void) {
     Formattable val;
     nf->parse(numStr, val, status);
     TEST_CHECK_STATUS(status);
-    TEST_ASSERT(Formattable::kDouble == val.getType());
-    TEST_ASSERT(1000000000 == val.getInt64(status));
+    TEST_ASSERT_EQUALS(Formattable::kDouble, val.getType());
+    TEST_ASSERT_EQUALS(1000000000LL, val.getInt64(status));
     TEST_CHECK_STATUS(status);
-    TEST_ASSERT(1000000000.6 == val.getDouble(status));
+    TEST_ASSERT_EQUALS(1000000000.6, val.getDouble(status));
     TEST_CHECK_STATUS(status);
 
     numStr = "100000000000000001.1";   // approx 1E17, parses as a double rather
@@ -2767,25 +2783,25 @@ void NumberFormatRegressionTest::Test8199(void) {
                                        //   even though int64 is more precise.
     nf->parse(numStr, val, status);
     TEST_CHECK_STATUS(status);
-    TEST_ASSERT(Formattable::kDouble == val.getType());
-    TEST_ASSERT(100000000000000001LL == val.getInt64(status));
+    TEST_ASSERT_EQUALS(Formattable::kDouble, val.getType());
+    TEST_ASSERT_EQUALS(100000000000000001LL, val.getInt64(status));
     TEST_CHECK_STATUS(status);
-    TEST_ASSERT(100000000000000000.0 == val.getDouble(status));
+    TEST_ASSERT_EQUALS(100000000000000000.0, val.getDouble(status));
     TEST_CHECK_STATUS(status);
 
     numStr = "1E17";  // Parses with the internal decimal number having non-zero exponent
     nf->parse(numStr, val, status);
     TEST_CHECK_STATUS(status);
-    TEST_ASSERT(Formattable::kInt64 == val.getType());
-    TEST_ASSERT(100000000000000000LL == val.getInt64());
-    TEST_ASSERT(1.0E17 == val.getDouble(status));
+    TEST_ASSERT_EQUALS(Formattable::kInt64, val.getType());
+    TEST_ASSERT_EQUALS(100000000000000000LL, val.getInt64());
+    TEST_ASSERT_EQUALS(1.0E17, val.getDouble(status));
     TEST_CHECK_STATUS(status);
 
     numStr = "9223372036854775807";  // largest int64_t
     nf->parse(numStr, val, status);
     TEST_CHECK_STATUS(status);
-    TEST_ASSERT(Formattable::kInt64 == val.getType());
-    TEST_ASSERT(9223372036854775807LL == val.getInt64());
+    TEST_ASSERT_EQUALS(Formattable::kInt64, val.getType());
+    TEST_ASSERT_EQUALS(9223372036854775807LL, val.getInt64());
     // In the following check, note that a substantial range of integers will
     //    convert to the same double value.  There are also platform variations
     //    in the rounding at compile time of double constants.
@@ -2796,31 +2812,31 @@ void NumberFormatRegressionTest::Test8199(void) {
     numStr = "-9223372036854775808";  // smallest int64_t
     nf->parse(numStr, val, status);
     TEST_CHECK_STATUS(status);
-    TEST_ASSERT(Formattable::kInt64 == val.getType());
-    // TEST_ASSERT(-9223372036854775808LL == val.getInt64()); // Compiler chokes on constant.
-    TEST_ASSERT((int64_t)0x8000000000000000LL == val.getInt64());
-    TEST_ASSERT(-9223372036854775808.0 == val.getDouble(status));
+    TEST_ASSERT_EQUALS(Formattable::kInt64, val.getType());
+    // TEST_ASSERT_EQUALS(-9223372036854775808LL, val.getInt64()); // Compiler chokes on constant.
+    TEST_ASSERT_EQUALS((int64_t)0x8000000000000000LL, val.getInt64());
+    TEST_ASSERT_EQUALS(-9223372036854775808.0, val.getDouble(status));
     TEST_CHECK_STATUS(status);
 
     numStr = "9223372036854775808";  // largest int64_t + 1
     nf->parse(numStr, val, status);
     TEST_CHECK_STATUS(status);
-    TEST_ASSERT(Formattable::kDouble == val.getType());
-    TEST_ASSERT(9223372036854775807LL == val.getInt64(status));
-    TEST_ASSERT(status == U_INVALID_FORMAT_ERROR);
+    TEST_ASSERT_EQUALS(Formattable::kDouble, val.getType());
+    TEST_ASSERT_EQUALS(9223372036854775807LL, val.getInt64(status));
+    TEST_ASSERT_EQUALS(status, U_INVALID_FORMAT_ERROR);
     status = U_ZERO_ERROR;
-    TEST_ASSERT(9223372036854775810.0 == val.getDouble(status));
+    TEST_ASSERT_EQUALS(9223372036854775810.0, val.getDouble(status));
     TEST_CHECK_STATUS(status);
 
     numStr = "-9223372036854775809";  // smallest int64_t - 1
     nf->parse(numStr, val, status);
     TEST_CHECK_STATUS(status);
-    TEST_ASSERT(Formattable::kDouble == val.getType());
-    // TEST_ASSERT(-9223372036854775808LL == val.getInt64(status));  // spurious compiler warnings
-    TEST_ASSERT((int64_t)0x8000000000000000LL == val.getInt64(status));
-    TEST_ASSERT(status == U_INVALID_FORMAT_ERROR);
+    TEST_ASSERT_EQUALS(Formattable::kDouble, val.getType());
+    // TEST_ASSERT_EQUALS(-9223372036854775808LL, val.getInt64(status));  // spurious compiler warnings
+    TEST_ASSERT_EQUALS((int64_t)0x8000000000000000LL, val.getInt64(status));
+    TEST_ASSERT_EQUALS(status, U_INVALID_FORMAT_ERROR);
     status = U_ZERO_ERROR;
-    TEST_ASSERT(-9223372036854775810.0 == val.getDouble(status));
+    TEST_ASSERT_EQUALS(-9223372036854775810.0, val.getDouble(status));
     TEST_CHECK_STATUS(status);
 
     // Test values near the limit of where doubles can represent all integers.
@@ -2834,25 +2850,25 @@ void NumberFormatRegressionTest::Test8199(void) {
     nf->parse(numStr, val, status);
     TEST_CHECK_STATUS(status);
     // printf("getInt64() returns %lld\n", val.getInt64(status));
-    TEST_ASSERT(Formattable::kDouble == val.getType());
-    TEST_ASSERT(9007199254740991LL == val.getInt64(status));
-    TEST_ASSERT(9007199254740991.0 == val.getDouble(status));
+    TEST_ASSERT_EQUALS(Formattable::kDouble, val.getType());
+    TEST_ASSERT_EQUALS(9007199254740991LL, val.getInt64(status));
+    TEST_ASSERT_EQUALS(9007199254740991.0, val.getDouble(status));
     TEST_CHECK_STATUS(status);
 
     status = U_ZERO_ERROR;
     numStr = "9007199254740992.1";  // 54 bits for the int part.
     nf->parse(numStr, val, status);
     TEST_CHECK_STATUS(status);
-    TEST_ASSERT(Formattable::kDouble == val.getType());
-    TEST_ASSERT(9007199254740992LL == val.getInt64(status));
-    TEST_ASSERT(9007199254740992.0 == val.getDouble(status));
+    TEST_ASSERT_EQUALS(Formattable::kDouble, val.getType());
+    TEST_ASSERT_EQUALS(9007199254740992LL, val.getInt64(status));
+    TEST_ASSERT_EQUALS(9007199254740992.0, val.getDouble(status));
     TEST_CHECK_STATUS(status);
 
     status = U_ZERO_ERROR;
     numStr = "9007199254740993.1";  // 54 bits for the int part.  Double will round
     nf->parse(numStr, val, status); //    the ones digit, putting it up to ...994
     TEST_CHECK_STATUS(status);
-    TEST_ASSERT(Formattable::kDouble == val.getType());
+    TEST_ASSERT_EQUALS(Formattable::kDouble, val.getType());
     TEST_ASSERT_EQUALS((int64_t)9007199254740993LL,val.getInt64(status));
     TEST_ASSERT_EQUALS((double)9007199254740994.0,(double)val.getDouble(status));
     TEST_CHECK_STATUS(status);
@@ -2892,7 +2908,7 @@ void NumberFormatRegressionTest::Test9780(void) {
     if (failure(status, "NumberFormat::createInstance", TRUE)){
         delete nf;
         return;
-    };
+    }
     DecimalFormat *df = dynamic_cast<DecimalFormat *>(nf);
     if(df == NULL) {
         errln("DecimalFormat needed to continue");
@@ -3006,7 +3022,6 @@ void NumberFormatRegressionTest::Test9677(void) {
         errln("FAIL: with different neg prefix , parse error %s\n", u_errorName(status));
         status = U_ZERO_ERROR;
     } else {
-;
         if(n!=-123456789) {
           errln("FAIL: with different neg prefix , unum_parse status %s, result %d expected -123456789\n", u_errorName(status), n);
         } else {