Imported Upstream version 58.1
[platform/upstream/icu.git] / source / test / intltest / numfmtst.cpp
index a4947b8..015836b 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
 /********************************************************************
  * COPYRIGHT:
  * Copyright (c) 1997-2016, International Business Machines Corporation and
@@ -2420,11 +2422,12 @@ void NumberFormatTest::TestSymbolsWithBadLocale(void) {
     for (i = 0; i < UPRV_LENGTHOF(badLocales); i++) {
         const char *localeName = badLocales[i];
         Locale locBad(localeName);
+        TEST_ASSERT_TRUE(!locBad.isBogus());
         UErrorCode status = U_ZERO_ERROR;
         UnicodeString intlCurrencySymbol((UChar)0xa4);
 
         intlCurrencySymbol.append((UChar)0xa4);
-
+        
         logln("Current locale is %s", Locale::getDefault().getName());
         Locale::setDefault(locBad, status);
         logln("Current locale is %s", Locale::getDefault().getName());
@@ -3929,9 +3932,9 @@ NumberFormatTest::TestCurrencyParsing() {
         {"en_US", "1", "USD", "$1.00", "USD1.00", "1.00 US dollar"},
         {"pa_IN", "1", "USD", "US$\\u00A01.00", "USD\\u00A01.00", "1.00 \\u0a2f\\u0a42.\\u0a10\\u0a38. \\u0a21\\u0a3e\\u0a32\\u0a30"},
         {"es_AR", "1", "USD", "US$\\u00A01,00", "USD\\u00A01,00", "1,00 d\\u00f3lar estadounidense"},
-        {"ar_EG", "1", "USD", "US$\\u00a0\\u0661\\u066b\\u0660\\u0660", "USD\\u00a0\\u0661\\u066b\\u0660\\u0660", "\\u0661\\u066b\\u0660\\u0660 \\u062f\\u0648\\u0644\\u0627\\u0631 \\u0623\\u0645\\u0631\\u064a\\u0643\\u064a"},
-        {"fa_CA", "1", "USD", "\\u200e$\\u06f1\\u066b\\u06f0\\u06f0", "\\u200eUSD\\u06f1\\u066b\\u06f0\\u06f0", "\\u200e\\u062f\\u0644\\u0627\\u0631 \\u0627\\u0645\\u0631\\u06cc\\u06a9\\u0627\\u06f1\\u066b\\u06f0\\u06f0"},
-        {"he_IL", "1", "USD", "1.00\\u00a0$", "1.00\\u00a0USD", "1.00 \\u05d3\\u05d5\\u05dc\\u05e8 \\u05d0\\u05de\\u05e8\\u05d9\\u05e7\\u05d0\\u05d9"},
+        {"ar_EG", "1", "USD", "\\u0661\\u066b\\u0660\\u0660\\u00a0US$", "\\u0661\\u066b\\u0660\\u0660\\u00a0USD", "\\u0661\\u066b\\u0660\\u0660 \\u062f\\u0648\\u0644\\u0627\\u0631 \\u0623\\u0645\\u0631\\u064a\\u0643\\u064a"},
+        {"fa_CA", "1", "USD", "\\u06f1\\u066b\\u06f0\\u06f0\\u00a0\\u061c$", "\\u06f1\\u066b\\u06f0\\u06f0\\u00a0\\u061cUSD", "\\u06f1\\u066b\\u06f0\\u06f0 \\u062f\\u0644\\u0627\\u0631 \\u0627\\u0645\\u0631\\u06cc\\u06a9\\u0627"},
+        {"he_IL", "1", "USD", "\\u200f1.00\\u00a0$", "\\u200f1.00\\u00a0USD", "1.00 \\u05d3\\u05d5\\u05dc\\u05e8 \\u05d0\\u05de\\u05e8\\u05d9\\u05e7\\u05d0\\u05d9"},
         {"hr_HR", "1", "USD", "1,00\\u00a0USD", "1,00\\u00a0USD", "1,00 Ameri\\u010dki dolar"},
         {"id_ID", "1", "USD", "US$1,00", "USD1,00", "1,00 Dolar Amerika Serikat"},
         {"it_IT", "1", "USD", "1,00\\u00a0US$", "1,00\\u00a0USD", "1,00 Dollaro Statunitense"},
@@ -4182,10 +4185,10 @@ NumberFormatTest::TestParseCurrencyInUCurr() {
         "Barbadian Dollar1.00",
         "Barbadian dollar1.00",
         "Barbadian dollars1.00",
-        "Belarusian New Ruble (1994\\u20131999)1.00",
+        "Belarusian Ruble (1994\\u20131999)1.00",
         "Belarusian Ruble1.00",
-        "Belarusian new ruble (1994\\u20131999)1.00",
-        "Belarusian new rubles (1994\\u20131999)1.00",
+        "Belarusian ruble (1994\\u20131999)1.00",
+        "Belarusian rubles (1994\\u20131999)1.00",
         "Belarusian ruble1.00",
         "Belarusian rubles1.00",
         "Belgian Franc (convertible)1.00",
@@ -4569,7 +4572,7 @@ NumberFormatTest::TestParseCurrencyInUCurr() {
         "Irish pound1.00",
         "Irish pounds1.00",
         "Israeli Pound1.00",
-        "Israeli new sheqel1.00",
+        "Israeli new shekel1.00",
         "Israeli pound1.00",
         "Israeli pounds1.00",
         "Italian Lira1.00",
@@ -4796,8 +4799,8 @@ NumberFormatTest::TestParseCurrencyInUCurr() {
         "Dutch Guilder1.00",
         "Dutch guilder1.00",
         "Dutch guilders1.00",
-        "Israeli New Sheqel1.00",
-        "Israeli New Sheqels1.00",
+        "Israeli New Shekel1.00",
+        "Israeli New Shekels1.00",
         "New Zealand Dollar1.00",
         "New Zealand dollar1.00",
         "New Zealand dollars1.00",
@@ -4870,12 +4873,12 @@ NumberFormatTest::TestParseCurrencyInUCurr() {
         "Paraguayan guarani1.00",
         "Paraguayan guaranis1.00",
         "Peruvian Inti1.00",
-        "Peruvian Nuevo Sol1.00",
+        "Peruvian Sol1.00",
         "Peruvian Sol (1863\\u20131965)1.00",
         "Peruvian inti1.00",
         "Peruvian intis1.00",
-        "Peruvian nuevo sol1.00",
-        "Peruvian nuevos soles1.00",
+        "Peruvian sol1.00",
+        "Peruvian soles1.00",
         "Peruvian sol (1863\\u20131965)1.00",
         "Peruvian soles (1863\\u20131965)1.00",
         "Philippine Peso1.00",
@@ -5341,10 +5344,10 @@ NumberFormatTest::TestParseCurrencyInUCurr() {
         "1.00 Barbadian Dollar random",
         "1.00 Barbadian dollar random",
         "1.00 Barbadian dollars random",
-        "1.00 Belarusian New Ruble (1994\\u20131999) random",
+        "1.00 Belarusian Ruble (1994\\u20131999) random",
         "1.00 Belarusian Ruble random",
-        "1.00 Belarusian new ruble (1994\\u20131999) random",
-        "1.00 Belarusian new rubles (1994\\u20131999) random",
+        "1.00 Belarusian ruble (1994\\u20131999) random",
+        "1.00 Belarusian rubles (1994\\u20131999) random",
         "1.00 Belarusian ruble random",
         "1.00 Belarusian rubles random",
         "1.00 Belgian Franc (convertible) random",
@@ -5612,7 +5615,7 @@ NumberFormatTest::TestParseCurrencyInUCurr() {
         "1.00 Irish pound random",
         "1.00 Irish pounds random",
         "1.00 Israeli Pound random",
-        "1.00 Israeli new sheqel random",
+        "1.00 Israeli new shekel random",
         "1.00 Israeli pound random",
         "1.00 Israeli pounds random",
         "1.00 Italian Lira random",
@@ -5752,8 +5755,8 @@ NumberFormatTest::TestParseCurrencyInUCurr() {
         "1.00 Dutch Guilder random",
         "1.00 Dutch guilder random",
         "1.00 Dutch guilders random",
-        "1.00 Israeli New Sheqel random",
-        "1.00 Israeli new sheqels random",
+        "1.00 Israeli New Shekel random",
+        "1.00 Israeli new shekels random",
         "1.00 New Zealand Dollar random",
         "1.00 New Zealand dollar random",
         "1.00 New Zealand dollars random",
@@ -5807,12 +5810,12 @@ NumberFormatTest::TestParseCurrencyInUCurr() {
         "1.00 Paraguayan guarani random",
         "1.00 Paraguayan guaranis random",
         "1.00 Peruvian Inti random",
-        "1.00 Peruvian Nuevo Sol random",
+        "1.00 Peruvian Sol random",
         "1.00 Peruvian Sol (1863\\u20131965) random",
         "1.00 Peruvian inti random",
         "1.00 Peruvian intis random",
-        "1.00 Peruvian nuevo sol random",
-        "1.00 Peruvian nuevos soles random",
+        "1.00 Peruvian sol random",
+        "1.00 Peruvian soles random",
         "1.00 Peruvian sol (1863\\u20131965) random",
         "1.00 Peruvian soles (1863\\u20131965) random",
         "1.00 Philippine Peso random",
@@ -6133,7 +6136,7 @@ NumberFormatTest::TestParseCurrencyInUCurr() {
         "Bangladeshi Tak1.00",
         "Barbadian Dolla1.00",
         "Bds1.00",
-        "Belarusian New Ruble (1994\\u201319991.00",
+        "Belarusian Ruble (1994\\u201319991.00",
         "Belarusian Rubl1.00",
         "Belgian Fran1.00",
         "Belgian Franc (convertible1.00",
@@ -8055,19 +8058,19 @@ void NumberFormatTest::TestAccountingCurrency() {
     UNumberFormatStyle style = UNUM_CURRENCY_ACCOUNTING;
 
     expect(NumberFormat::createInstance("en_US", style, status),
-        (Formattable)1234.5, "$1,234.50", TRUE, status);
+        (Formattable)(double)1234.5, "$1,234.50", TRUE, status);
     expect(NumberFormat::createInstance("en_US", style, status),
-        (Formattable)-1234.5, "($1,234.50)", TRUE, status);
+        (Formattable)(double)-1234.5, "($1,234.50)", TRUE, status);
     expect(NumberFormat::createInstance("en_US", style, status),
-        (Formattable)0, "$0.00", TRUE, status);
+        (Formattable)(double)0, "$0.00", TRUE, status);
     expect(NumberFormat::createInstance("en_US", style, status),
-        (Formattable)-0.2, "($0.20)", TRUE, status);
+        (Formattable)(double)-0.2, "($0.20)", TRUE, status);
     expect(NumberFormat::createInstance("ja_JP", style, status),
-        (Formattable)10000, UnicodeString("\\uFFE510,000").unescape(), TRUE, status);
+        (Formattable)(double)10000, UnicodeString("\\uFFE510,000").unescape(), TRUE, status);
     expect(NumberFormat::createInstance("ja_JP", style, status),
-        (Formattable)-1000.5, UnicodeString("(\\uFFE51,000)").unescape(), FALSE, status);
+        (Formattable)(double)-1000.5, UnicodeString("(\\uFFE51,000)").unescape(), FALSE, status);
     expect(NumberFormat::createInstance("de_DE", style, status),
-        (Formattable)-23456.7, UnicodeString("-23.456,70\\u00A0\\u20AC").unescape(), TRUE, status);
+        (Formattable)(double)-23456.7, UnicodeString("-23.456,70\\u00A0\\u20AC").unescape(), TRUE, status);
 }
 
 // for #5186
@@ -8122,7 +8125,7 @@ void NumberFormatTest::TestCurrencyUsage() {
 
             // test the getter here
             UCurrencyUsage curUsage = fmt->getCurrencyUsage();
-            assertEquals("Test usage getter - standard", curUsage, UCURR_USAGE_STANDARD);
+            assertEquals("Test usage getter - standard", (int32_t)curUsage, (int32_t)UCURR_USAGE_STANDARD);
 
             fmt->setCurrencyUsage(UCURR_USAGE_CASH, &status);
         }else{
@@ -8134,7 +8137,7 @@ void NumberFormatTest::TestCurrencyUsage() {
 
         // must be usage = cash
         UCurrencyUsage curUsage = fmt->getCurrencyUsage();
-        assertEquals("Test usage getter - cash", curUsage, UCURR_USAGE_CASH);
+        assertEquals("Test usage getter - cash", (int32_t)curUsage, (int32_t)UCURR_USAGE_CASH);
 
         UnicodeString cash_currency;
         fmt->format(agent,cash_currency);
@@ -8312,9 +8315,9 @@ void NumberFormatTest::TestFastPathConsistent11524() {
     }
     fmt->setMaximumIntegerDigits(INT32_MIN);
     UnicodeString appendTo;
-    assertEquals("", "0", fmt->format(123, appendTo));
+    assertEquals("", "0", fmt->format((int32_t)123, appendTo));
     appendTo.remove();
-    assertEquals("", "0", fmt->format(12345, appendTo));
+    assertEquals("", "0", fmt->format((int32_t)12345, appendTo));
     delete fmt;
 }
 
@@ -8400,7 +8403,7 @@ void NumberFormatTest::TestBenchmark() {
     DecimalFormat fmt("0.0000000", new DecimalFormatSymbols(sym), status);
 //    DecimalFormat fmt("0.00000E0", new DecimalFormatSymbols(sym), status);
 //    DecimalFormat fmt("0", new DecimalFormatSymbols(sym), status);
-    FieldPosition fpos(0);
+    FieldPosition fpos(FieldPosition::DONT_CARE);
     clock_t start = clock();
     for (int32_t i = 0; i < 1000000; ++i) {
         UnicodeString append;
@@ -8415,7 +8418,7 @@ void NumberFormatTest::TestBenchmark() {
 
     UErrorCode status = U_ZERO_ERROR;
     MessageFormat fmt("{0, plural, one {I have # friend.} other {I have # friends.}}", status);
-    FieldPosition fpos(0);
+    FieldPosition fpos(FieldPosition::DONT_CARE);
     Formattable one(1.0);
     Formattable three(3.0);
     clock_t start = clock();
@@ -8432,7 +8435,7 @@ void NumberFormatTest::TestBenchmark() {
     Locale en("en");
     Measure measureC(23, MeasureUnit::createCelsius(status), status);
     MeasureFormat fmt(en, UMEASFMT_WIDTH_WIDE, status);
-    FieldPosition fpos(0);
+    FieldPosition fpos(FieldPosition::DONT_CARE);
     clock_t start = clock();
     for (int32_t i = 0; i < 1000000; ++i) {
         UnicodeString appendTo;
@@ -8487,13 +8490,13 @@ void NumberFormatTest::TestCtorApplyPatternDifference() {
     assertEquals(
             "ctor favors precision of currency",
             "$5.00",
-            fmt.format(5, result));
+            fmt.format((double)5, result));
     result.remove();
     fmt.applyPattern(pattern.unescape(), status);
     assertEquals(
             "applyPattern favors precision of pattern",
             "$5",
-            fmt.format(5, result));
+            fmt.format((double)5, result));
 }
 
 void NumberFormatTest::Test11868() {