]> granicus.if.org Git - icu/commitdiff
ICU-13183 on branch - Add more tests and sample data
authorPeter Edberg <pedberg@unicode.org>
Tue, 23 May 2017 02:37:37 +0000 (02:37 +0000)
committerPeter Edberg <pedberg@unicode.org>
Tue, 23 May 2017 02:37:37 +0000 (02:37 +0000)
X-SVN-Rev: 40127

icu4c/source/data/locales/zh.txt
icu4c/source/test/intltest/dtptngts.cpp
icu4j/main/shared/data/icudata.jar
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateTimeGeneratorTest.java

index 17a3c7d547274cf6c8b43125e101cc3fa1dfe3d8..2a95662159f2a2eeac6d2d700bdb9b7510a87fc1 100644 (file)
@@ -1133,7 +1133,12 @@ zh{
                 Timezone{"{1}{0}"}
             }
             availableFormats{
+                Bh{"Bh时"}
+                Bhm{"Bh:mm"}
+                Bhms{"Bh:mm:ss"}
                 E{"ccc"}
+                EBhm{"EBh:mm"}
+                EBms{"EBh:mm:ss"}
                 EHm{"EHH:mm"}
                 EHms{"EHH:mm:ss"}
                 Ed{"d日E"}
index 422f9f8902934afc411cf5dba948fc0fca0e5827..714ee2e19b8e497fd3704a85db25d4b328961c39 100644 (file)
@@ -1089,31 +1089,39 @@ void IntlTestDateTimePatternGeneratorAPI::testStaticGetSkeleton(/*char *par*/)
 }
 
 void IntlTestDateTimePatternGeneratorAPI::testC() {
-    UErrorCode status = U_ZERO_ERROR;
-    const int32_t numLocales = 11;
-
-    const char* tests[numLocales][3] = {
+    const char* tests[][3] = {
             // These may change with actual data for Bhmm/bhmm skeletons
-            {"zh", "Cm", "h:mm B"},
-            {"zh", "CCCm", "h:mm BBBB"},
-            {"zh", "CCCCCm", "h:mm BBBBB"},
-            {"zh", "Cm", "h:mm B"},
-            {"de", "Cm", "HH:mm"},
-            {"en", "Cm", "h:mm a"},
-            {"en", "CCCm", "h:mm aaaa"},
-            {"en", "CCCCCm", "h:mm aaaaa"},
-            {"en-BN", "Cm", "h:mm b"},
-            {"gu-IN", "Cm", "h:mm B"},
-            {"und-IN", "Cm", "h:mm a"},
+            {"zh",     "Cm",      "Bh:mm"},
+            {"zh",     "CCm",     "Bhh:mm"},
+            {"zh",     "CCCm",    "BBBBh:mm"},
+            {"zh",     "CCCCm",   "BBBBhh:mm"},
+            {"zh",     "CCCCCm",  "BBBBBh:mm"},
+            {"zh",     "CCCCCCm", "BBBBBhh:mm"},
+            {"de",     "Cm",      "HH:mm"},
+            {"de",     "CCm",     "HH:mm"},
+            {"de",     "CCCm",    "HH:mm"},
+            {"de",     "CCCCm",   "HH:mm"},
+            {"en",     "Cm",      "h:mm a"},
+            {"en",     "CCm",     "hh:mm a"},
+            {"en",     "CCCm",    "h:mm aaaa"},
+            {"en",     "CCCCm",   "hh:mm aaaa"},
+            {"en",     "CCCCCm",  "h:mm aaaaa"},
+            {"en",     "CCCCCCm", "hh:mm aaaaa"},
+            {"en-BN",  "Cm",      "h:mm b"},
+            {"gu-IN",  "Cm",      "h:mm B"},
+            {"und-IN", "Cm",      "h:mm a"}
     };
 
-    for (int32_t i = 0; i < numLocales; ++i) {
+    UErrorCode status = U_ZERO_ERROR;
+    int32_t numTests = UPRV_LENGTHOF(tests);
+    for (int32_t i = 0; i < numTests; ++i) {
         DateTimePatternGenerator *gen = DateTimePatternGenerator::createInstance(Locale(tests[i][0]), status);
         if (gen == NULL) {
             dataerrln("FAIL: DateTimePatternGenerator::createInstance failed for %s", tests[i][0]);
             return;
         }
-        UnicodeString pattern = gen->getBestPattern(tests[i][1], status);
+        UDateTimePatternMatchOptions options = UDATPG_MATCH_HOUR_FIELD_LENGTH;
+        UnicodeString pattern = gen->getBestPattern(tests[i][1], options, status);
         UnicodeString expectedPattern = tests[i][2];
 
         char message[100] = "\0";
@@ -1140,18 +1148,33 @@ void IntlTestDateTimePatternGeneratorAPI::testSkeletonsWithDayPeriods() {
     };
     const char* testItems[][2] = {
         // sample requested skeletons and results
-        // skel    pattern
-        { "H",     "H"},
-        { "aH",    "H"},
-        { "BH",    "H"},
-        { "h",     "h a"},
-        { "ah",    "h a"},
-        { "bh",    "h b"},
-        { "Bh",    "B h"},
-        { "BBBBh", "BBBB h"},
-        { "a",     "a"},
-        { "b",     "b"},
-        { "B",     "B"}
+        // skel     pattern
+        { "H",      "H"},
+        { "HH",     "HH"},
+        { "aH",     "H"},
+        { "aHH",    "HH"},
+        { "BH",     "H"},
+        { "BHH",    "HH"},
+        { "BBBBH",  "H"},
+        { "h",      "h a"},
+        { "hh",     "hh a"},
+        { "ah",     "h a"},
+        { "ahh",    "hh a"},
+        { "aaaah",  "h aaaa"},
+        { "aaaahh", "hh aaaa"},
+        { "bh",     "h b"},
+        { "bhh",    "hh b"},
+        { "bbbbh",  "h bbbb"},
+        { "Bh",     "B h"},
+        { "Bhh",    "B hh"},
+        { "BBBBh",  "BBBB h"},
+        { "BBBBhh", "BBBB hh"},
+        { "a",      "a"},
+        { "aaaaa",  "aaaaa"},
+        { "b",      "b"},
+        { "bbbb",   "bbbb"},
+        { "B",      "B"},
+        { "BBBB",  "BBBB"},
     };
     UErrorCode status = U_ZERO_ERROR;
     DateTimePatternGenerator *gen = DateTimePatternGenerator::createEmptyInstance(status);
@@ -1171,7 +1194,8 @@ void IntlTestDateTimePatternGeneratorAPI::testSkeletonsWithDayPeriods() {
             len = UPRV_LENGTHOF(testItems);
             for (i = 0; i < len; i++) {
                 status = U_ZERO_ERROR;
-                UnicodeString result = gen->getBestPattern(UnicodeString(testItems[i][0]), status);
+                UDateTimePatternMatchOptions options = UDATPG_MATCH_HOUR_FIELD_LENGTH;
+                UnicodeString result = gen->getBestPattern(UnicodeString(testItems[i][0]), options, status);
                 if (U_FAILURE(status)) {
                     errln("ERROR: getBestPattern %s fail, status: %s", testItems[i][0], u_errorName(status));
                 } else if (result != UnicodeString(testItems[i][1])) {
index c9de7affbae22b868432b96e5d0ee6d64a280a84..83fd6148dfa81855b7493868dd7d2e6fbb92135d 100755 (executable)
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:be32359b49e989b80821acea019b8e01807b726a4f57bf1322235f03c0c11709
-size 12153095
+oid sha256:a2e7756f45badde8ea612be307feb2a7674c0c52062e524c30a653fced4b710b
+size 12153152
index 2bfe975403997417d01d757383a7db6b62d2cfcc..fb8c5126c47ed077202c154cec6d7b9ffc4970c9 100644 (file)
@@ -56,21 +56,31 @@ public class DateTimeGeneratorTest extends TestFmwk {
     public void TestC() {
         String[][] tests = {
                 // These may change with actual data for Bhmm/bhmm skeletons
-                {"zh", "Cm", "h:mm B"},
-                {"zh", "CCCm", "h:mm BBBB"},
-                {"zh", "CCCCCm", "h:mm BBBBB"},
-                {"de", "Cm", "HH:mm"},
-                {"en", "Cm", "h:mm a"},
-                {"en", "CCCm", "h:mm aaaa"},
-                {"en", "CCCCCm", "h:mm aaaaa"},
-                {"en-BN", "Cm", "h:mm b"},
-                {"gu-IN", "Cm", "h:mm B"},
-                {"und-IN", "Cm", "h:mm a"},
+                {"zh",     "Cm",      "Bh:mm"},
+                {"zh",     "CCm",     "Bhh:mm"},
+                {"zh",     "CCCm",    "BBBBh:mm"},
+                {"zh",     "CCCCm",   "BBBBhh:mm"},
+                {"zh",     "CCCCCm",  "BBBBBh:mm"},
+                {"zh",     "CCCCCCm", "BBBBBhh:mm"},
+                {"de",     "Cm",      "HH:mm"},
+                {"de",     "CCm",     "HH:mm"},
+                {"de",     "CCCm",    "HH:mm"},
+                {"de",     "CCCCm",   "HH:mm"},
+                {"en",     "Cm",      "h:mm a"},
+                {"en",     "CCm",     "hh:mm a"},
+                {"en",     "CCCm",    "h:mm aaaa"},
+                {"en",     "CCCCm",   "hh:mm aaaa"},
+                {"en",     "CCCCCm",  "h:mm aaaaa"},
+                {"en",     "CCCCCCm", "hh:mm aaaaa"},
+                {"en-BN",  "Cm",      "h:mm b"},
+                {"gu-IN",  "Cm",      "h:mm B"},
+                {"und-IN", "Cm",      "h:mm a"},
         };
         for (String[] test : tests) {
             DateTimePatternGenerator gen = DateTimePatternGenerator.getInstance(ULocale.forLanguageTag(test[0]));
             String skeleton = test[1];
-            String pattern = gen.getBestPattern(skeleton);
+            int options = DateTimePatternGenerator.MATCH_HOUR_FIELD_LENGTH;
+            String pattern = gen.getBestPattern(skeleton, options);
             assertEquals(test[0] + "/" + skeleton, test[2], pattern);
         }
     }
@@ -86,18 +96,33 @@ public class DateTimeGeneratorTest extends TestFmwk {
         };
         String[][] testItems = {
                 // sample requested skeletons and results
-                // skel    pattern
-                { "H",     "H"},
-                { "aH",    "H"},
-                { "BH",    "H"},
-                { "h",     "h a"},
-                { "ah",    "h a"},
-                { "bh",    "h b"},
-                { "Bh",    "B h"},
-                { "BBBBh", "BBBB h"},
-                { "a",     "a"},
-                { "b",     "b"},
-                { "B",     "B"},
+                // skel     pattern
+                { "H",      "H"},
+                { "HH",     "HH"},
+                { "aH",     "H"},
+                { "aHH",    "HH"},
+                { "BH",     "H"},
+                { "BHH",    "HH"},
+                { "BBBBH",  "H"},
+                { "h",      "h a"},
+                { "hh",     "hh a"},
+                { "ah",     "h a"},
+                { "ahh",    "hh a"},
+                { "aaaah",  "h aaaa"},
+                { "aaaahh", "hh aaaa"},
+                { "bh",     "h b"},
+                { "bhh",    "hh b"},
+                { "bbbbh",  "h bbbb"},
+                { "Bh",     "B h"},
+                { "Bhh",    "B hh"},
+                { "BBBBh",  "BBBB h"},
+                { "BBBBhh", "BBBB hh"},
+                { "a",      "a"},
+                { "aaaaa",  "aaaaa"},
+                { "b",      "b"},
+                { "bbbb",   "bbbb"},
+                { "B",      "B"},
+                { "BBBB",  "BBBB"},
         };
         DateTimePatternGenerator gen = DateTimePatternGenerator.getEmptyInstance();
         DateTimePatternGenerator.PatternInfo returnInfo = new DateTimePatternGenerator.PatternInfo();
@@ -109,7 +134,8 @@ public class DateTimeGeneratorTest extends TestFmwk {
             }
         }
         for (String[] testItem : testItems) {
-            String pattern = gen.getBestPattern(testItem[0]);
+            int options = DateTimePatternGenerator.MATCH_HOUR_FIELD_LENGTH;
+            String pattern = gen.getBestPattern(testItem[0], options);
             if (!pattern.equals(testItem[1])) {
                  errln("getBestPattern  for skeleton " + testItem[0] + ", expected " + testItem[1] +  ", got " + pattern);
             }