]> gitweb.fperrin.net Git - Dictionary.git/blobdiff - jars/icu4j-52_1/main/tests/core/src/com/ibm/icu/dev/test/format/PluralFormatTest.java
Upgrade ICU4J.
[Dictionary.git] / jars / icu4j-52_1 / main / tests / core / src / com / ibm / icu / dev / test / format / PluralFormatTest.java
similarity index 84%
rename from jars/icu4j-4_8_1_1/main/tests/core/src/com/ibm/icu/dev/test/format/PluralFormatTest.java
rename to jars/icu4j-52_1/main/tests/core/src/com/ibm/icu/dev/test/format/PluralFormatTest.java
index eb2a3e2747b3b065498f913e6a185c109fb85fee..5ee4c92eb747f4b0478bff0b9e1ed31da4d2cd10 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *******************************************************************************
- * Copyright (C) 2007-2010, International Business Machines Corporation and    *
+ * Copyright (C) 2007-2013, International Business Machines Corporation and    *
  * others. All Rights Reserved.                                                *
  *******************************************************************************
  */
@@ -25,7 +25,7 @@ public class PluralFormatTest extends TestFmwk {
     new PluralFormatTest().run(args);
   }
   
-  private void helperTestRules(String localeIDs, String testPattern, Map changes) {
+  private void helperTestRules(String localeIDs, String testPattern, Map<Integer,String> changes) {
     String[] locales = Utility.split(localeIDs, ',');
     
     // Create example outputs for all supported locales.
@@ -54,8 +54,9 @@ public class PluralFormatTest extends TestFmwk {
         log("plf: " + plf);
         String expected = (String) changes.get(new Integer(0));
         for (int n = 0; n < 200; ++n) {
-          if (changes.get(new Integer(n)) != null) {
-            expected = (String) changes.get(new Integer(n));
+          String value = changes.get(n);
+          if (value != null) {
+            expected = value;
           }
           assertEquals("Locale: " + locales[i] + ", number: " + n,
                        expected, plf.format(n));
@@ -75,8 +76,8 @@ public class PluralFormatTest extends TestFmwk {
   }
   
   public void TestSingular1Locales() {
-    String localeIDs = "bem,da,de,el,en,eo,es,et,fi,fo,he,it,nb,nl,nn,no,pt,pt_PT,sv,af,bg,bn,ca,eu,fur,fy,gu,ha,is,ku,lb,ml," +
-        "mr,nah,ne,om,or,pa,pap,ps,so,sq,sw,ta,te,tk,ur,zu,mn,gsw,rm";
+    String localeIDs = "bem,da,de,el,en,eo,es,et,fi,fo,he,it,nb,nl,nn,no,pt,pt_PT,sv,af,bg,ca,eu,fur,fy,ha,ku,lb,ml," +
+        "nah,ne,om,or,pap,ps,so,sq,sw,ta,te,tk,ur,mn,gsw,rm";
     String testPattern = "one{one} other{other}";
     Map changes = new HashMap();
     changes.put(new Integer(0), "other");
@@ -86,7 +87,7 @@ public class PluralFormatTest extends TestFmwk {
   }
   
   public void TestSingular01Locales() {
-    String localeIDs = "ff,fr,kab";
+    String localeIDs = "ff,fr,kab,gu,mr,pa,zu,bn";
     String testPattern = "one{one} other{other}";
     Map changes = new HashMap();
     changes.put(new Integer(0), "one");
@@ -100,13 +101,20 @@ public class PluralFormatTest extends TestFmwk {
     Map changes = new HashMap();
     changes.put(new Integer(0), "zero");
     changes.put(new Integer(1), "one");
-    changes.put(new Integer(2), "other");
     for (int i = 2; i < 20; ++i) {
+      if (i < 10) {
+        changes.put(new Integer(i), "other");
+      } else {
+        changes.put(new Integer(i), "zero");
+      }
+      changes.put(new Integer(i*10), "zero");
       if (i == 11) {
-        continue;
+        changes.put(new Integer(i*10 + 1), "zero");
+        changes.put(new Integer(i*10 + 2), "zero");
+      } else {
+        changes.put(new Integer(i*10 + 1), "one");
+        changes.put(new Integer(i*10 + 2), "other");
       }
-      changes.put(new Integer(i*10 + 1), "one");
-      changes.put(new Integer(i*10 + 2), "other");
     }
     helperTestRules(localeIDs, testPattern, changes);
   }
@@ -155,7 +163,7 @@ public class PluralFormatTest extends TestFmwk {
   }
   
   public void TestPaucalExcept11_14() {
-      String localeIDs = "hr,ru,sr,uk";
+      String localeIDs = "hr,sr,uk";
       String testPattern = "one{one} few{few} other{other}";
       Map changes = new HashMap();
       changes.put(new Integer(0), "other");
@@ -173,6 +181,36 @@ public class PluralFormatTest extends TestFmwk {
       helperTestRules(localeIDs, testPattern, changes);
   }
   
+  public void TestPaucalRu() {
+      String localeIDs = "ru";
+      String testPattern = "one{one} many{many} other{other}";
+      Map changes = new HashMap();
+      for (int i = 0; i < 200; i+=10) {
+          if (i == 10 || i == 110) {
+              put(i, 0, 9, "many", changes);
+              continue;
+          }
+          put(i, 0, "many", changes);
+          put(i, 1, "one", changes);
+          put(i, 2, 4, "other", changes);
+          put(i, 5, 9, "many", changes);
+      }
+      helperTestRules(localeIDs, testPattern, changes);
+  }
+  
+  public <T> void put(int base, int start, int end, T value, Map<Integer, T> m) {
+      for (int i = start; i <= end; ++i) {
+          if (m.containsKey(base + i)) {
+              throw new IllegalArgumentException();
+          }
+          m.put(base + i, value);
+      }
+  }
+  
+  public <T> void put(int base, int start, T value, Map<Integer, T> m) {
+      put(base, start, start, value, m);
+  }
+  
   public void TestSingularPaucal() {
       String localeIDs = "cs,sk";
       String testPattern = "one{one} few{few} other{other}";