]> granicus.if.org Git - icu/commitdiff
ICU-20119 63rc BRS, cldr 34-alpha2 part 3: icu4j code for region,pluralRange; tests...
authorPeter Edberg <pedberg@apple.com>
Thu, 20 Sep 2018 22:24:42 +0000 (15:24 -0700)
committerShane Carr <shane@unicode.org>
Thu, 27 Sep 2018 21:27:41 +0000 (14:27 -0700)
icu4j/main/classes/core/src/com/ibm/icu/number/NumberRangeFormatterImpl.java
icu4j/main/classes/core/src/com/ibm/icu/util/Region.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/MeasureUnitTest.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberRegressionTests.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/number/NumberRangeFormatterTest.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/serializable/FormatHandler.java

index 71aafe51cd1e8174e4ca5a1c85db6051e7e75694..437f8cef3f60fa0f9089ed282c53db30f8b94a96 100644 (file)
@@ -71,7 +71,7 @@ class NumberRangeFormatterImpl {
                 }
                 if (key.contentEquals("approximately") && approximatelyPattern == null) {
                     String pattern = value.getString();
-                    approximatelyPattern = SimpleFormatterImpl.compileToStringMinMaxArguments(pattern, sb, 2, 2);
+                    approximatelyPattern = SimpleFormatterImpl.compileToStringMinMaxArguments(pattern, sb, 1, 1); // 1 arg, as in "~{0}"
                 }
             }
         }
index 2a1f852ed5e5f5e2f917713ac81584b1a548656d..2fabbb0c4cebaaf5f6bcc7f6b09a1ecddcd00de9 100644 (file)
@@ -324,9 +324,10 @@ public class Region implements Comparable<Region> {
         for ( int i = 0 ; i < territoryContainment.getSize(); i++ ) {
             UResourceBundle mapping = territoryContainment.get(i);
             String parent = mapping.getKey();
-            if (parent.equals("containedGroupings") || parent.equals("deprecated")) {
+            if (parent.equals("containedGroupings") || parent.equals("deprecated") || parent.equals("grouping")) {
                 continue; // handle new pseudo-parent types added in ICU data per cldrbug 7808; for now just skip.
                 // #11232 is to do something useful with these.
+                // Also skip "grouping" which has multi-level structure below from CLDR 34.
             }
             Region parentRegion = regionIDMap.get(parent);
             for ( int j = 0 ; j < mapping.getSize(); j++ ) {
index f036da7390649b7e628cf17ee0bb8f5ea0604f3f..b7f842a49dffcf15ae5cef7907450d8a38bdcb93 100644 (file)
@@ -2721,9 +2721,23 @@ public class MeasureUnitTest extends TestFmwk {
         {
             MeasureFormat a1 = (MeasureFormat) a;
             MeasureFormat b1 = (MeasureFormat) b;
-            return a1.getLocale().equals(b1.getLocale())
-                    && a1.getWidth().equals(b1.getWidth())
-                    && nfh.hasSameBehavior(a1.getNumberFormat(), b1.getNumberFormat());
+            boolean getLocaleEqual = a1.getLocale().equals(b1.getLocale());
+            boolean getWidthEqual = a1.getWidth().equals(b1.getWidth());
+            boolean numFmtHasSameBehavior = nfh.hasSameBehavior(a1.getNumberFormat(), b1.getNumberFormat());
+            if (getLocaleEqual && getWidthEqual && numFmtHasSameBehavior) {
+                return true;
+            }
+            System.out.println("MeasureFormatHandler.hasSameBehavior fails:");
+            if (!getLocaleEqual) {
+                System.out.println("- getLocale equality fails: old a1: " + a1.getLocale().getName() + "; test b1: " + b1.getLocale().getName());
+            }
+            if (!getWidthEqual) {
+                System.out.println("- getWidth equality fails: old a1: " + a1.getWidth().name() + "; test b1: " + b1.getWidth().name());
+            }
+            if (!numFmtHasSameBehavior) {
+                System.out.println("- getNumberFormat hasSameBehavior fails");
+            }
+            return false;
         }
     }
 }
index b5efe969c82f13c270dc0ed568573a40b954d8ed..e9e89fd90e809e1efb3d7b7b1bcbbebc055a841d 100644 (file)
@@ -257,14 +257,14 @@ public class NumberRegressionTests extends TestFmwk {
         // Space as group separator
 
         logln("...applyLocalizedPattern # ###,00;(# ###,00) ");
-        ((DecimalFormat)nf).applyLocalizedPattern("#\u00a0###,00;(#\u00a0###,00)");
+        ((DecimalFormat)nf).applyLocalizedPattern("#\u202f###,00;(#\u202f###,00)");
         logln("nf toPattern2: " + ((DecimalFormat)nf).toPattern());
         logln("nf toLocPattern2: " + ((DecimalFormat)nf).toLocalizedPattern());
         String buffer = nf.format(1234);
-        if (!buffer.equals("1\u00a0234,00"))
+        if (!buffer.equals("1\u202f234,00"))
             errln("nf : " + buffer); // Expect 1 234,00
         buffer = nf.format(-1234);
-        if (!buffer.equals("(1\u00a0234,00)"))
+        if (!buffer.equals("(1\u202f234,00)"))
             errln("nf : " + buffer); // Expect (1 234,00)
 
         // Erroneously prints:
index 52933d0b271524cb9bb62c812ece646e53e03422..88672727315ea25330f7eb86960b6373831067ec 100644 (file)
@@ -118,30 +118,30 @@ public class NumberRangeFormatterTest {
             NumberRangeFormatter.with()
                 .numberFormatterBoth(NumberFormatter.with().unit(MeasureUnit.FAHRENHEIT).unitWidth(UnitWidth.FULL_NAME)),
             new ULocale("fr-FR"),
-            "1–5 degrés Fahrenheit",
-            "~5 degrés Fahrenheit",
-            "~5 degrés Fahrenheit",
-            "0–3 degrés Fahrenheit",
-            "~0 degré Fahrenheit",
-            "3–3 000 degrés Fahrenheit",
-            "3 000–5 000 degrés Fahrenheit",
-            "4 999–5 001 degrés Fahrenheit",
-            "~5 000 degrés Fahrenheit",
-            "5 000–5 000 000 degrés Fahrenheit");
+            "1–5\u00A0degrés Fahrenheit",
+            "≈5\u00A0degrés Fahrenheit",
+            "≈5\u00A0degrés Fahrenheit",
+            "0–3\u00A0degrés Fahrenheit",
+            "≈0\u00A0degré Fahrenheit",
+            "3–3\u202F000\u00A0degrés Fahrenheit",
+            "3\u202F000–5\u202F000\u00A0degrés Fahrenheit",
+            "4\u202F999–5\u202F001\u00A0degrés Fahrenheit",
+            "≈5\u202F000\u00A0degrés Fahrenheit",
+            "5\u202F000–5\u202F000\u202F000\u00A0degrés Fahrenheit");
 
         assertFormatRange(
             "Locale with custom range separator",
             NumberRangeFormatter.with(),
             new ULocale("ja"),
             "1~5",
-            "~5",
-            "~5",
+            "約 5",
+            "約 5",
             "0~3",
-            "~0",
+            "約 0",
             "3~3,000",
             "3,000~5,000",
             "4,999~5,001",
-            "~5,000",
+            "約 5,000",
             "5,000~5,000,000");
 
         assertFormatRange(
@@ -417,14 +417,14 @@ public class NumberRangeFormatterTest {
                 .numberFormatterBoth(NumberFormatter.with().notation(Notation.compactLong())),
             new ULocale("de-CH"),
             "1–5",
-            "~5",
-            "~5",
+            "5",
+            "5",
             "0–3",
-            "~0",
+            "0",
             "3–3 Tausend",
             "3–5 Tausend",
-            "~5 Tausend",
-            "~5 Tausend",
+            "5 Tausend",
+            "5 Tausend",
             "5 Tausend – 5 Millionen");
 
         assertFormatRange(
@@ -434,14 +434,14 @@ public class NumberRangeFormatterTest {
                 .numberFormatterBoth(NumberFormatter.with().notation(Notation.compactLong())),
                 new ULocale("de-CH"),
             "1–5",
-            "~5",
-            "~5",
+            "5",
+            "5",
             "0–3",
-            "~0",
+            "0",
             "3–3 Tausend",
             "3 Tausend – 5 Tausend",
-            "~5 Tausend",
-            "~5 Tausend",
+            "5 Tausend",
+            "5 Tausend",
             "5 Tausend – 5 Millionen");
 
         assertFormatRange(
index d82dface0fcee900a916a5a4a6c8ffeb22857198..7bb5e98fc8acce3295a5870a4fdde0f32e08a534 100644 (file)
@@ -1106,8 +1106,10 @@ public class FormatHandler
             NumberFormat format_b = (NumberFormat) b;
             double number = 1234.56;
 
-            String result_a = format_a.format(number);
-            String result_b = format_b.format(number);
+            // In CLDR 34, French changed grouping separator from \u00a0 to \u202f;
+            // here we undo that in formatted result so serialization tests don't fail
+            String result_a = format_a.format(number).replace('\u202f', '\u00a0');
+            String result_b = format_b.format(number).replace('\u202f', '\u00a0');
             boolean equal = result_a.equals(result_b);
             if (!equal) {
                 System.out.println(format_a+" "+format_b);