]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/intltest/listformattertest.cpp
ICU-62107.0.1.tar.gz
[apple/icu.git] / icuSources / test / intltest / listformattertest.cpp
index 62cdd34c823ed03bc08ec99750d73f463fef96b1..af49baa05dd51cb9b69a76384b6bc49607592ea0 100644 (file)
@@ -1,3 +1,5 @@
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
 /*
 *******************************************************************************
 *
@@ -6,7 +8,7 @@
 *
 *******************************************************************************
 *   file name:  listformattertest.cpp
-*   encoding:   US-ASCII
+*   encoding:   UTF-8
 *   tab size:   8 (not used)
 *   indentation:4
 *
@@ -145,6 +147,50 @@ void ListFormatterTest::TestEnglishUS() {
     CheckFourCases("en_US", one, two, three, four, results);
 }
 
+// Tests resource loading and inheritance when region sublocale
+// has only partial data for the listPattern element (overriding
+// some of the parent data). #12994
+void ListFormatterTest::TestEnglishGB() {
+    UnicodeString results[4] = {
+        one,
+        one + " and " + two,
+        one + ", " + two + " and " + three,
+        one + ", " + two + ", " + three + " and " + four
+    };
+
+    CheckFourCases("en_GB", one, two, three, four, results);
+}
+
+// Tests resource loading and inheritance when region sublocale
+// has only partial data for the listPattern element (overriding
+// some of the parent data). #12994
+void ListFormatterTest::TestNynorsk() {
+    UnicodeString results[4] = {
+        one,
+        one + " og " + two,
+        one + ", " + two + " og " + three,
+        one + ", " + two + ", " + three + " og " + four
+    };
+
+    CheckFourCases("nn", one, two, three, four, results);
+}
+
+// Tests resource loading and inheritance when region sublocale
+// has only partial data for the listPattern element (overriding
+// some of the parent data). #12994
+void ListFormatterTest::TestChineseTradHK() {
+    UnicodeString and_string = UnicodeString("\\u53CA", -1, US_INV).unescape();
+    UnicodeString comma_string = UnicodeString("\\u3001", -1, US_INV).unescape();
+    UnicodeString results[4] = {
+        one,
+        one + and_string + two,
+        one + comma_string + two + and_string + three,
+        one + comma_string + two + comma_string + three + and_string + four
+    };
+
+    CheckFourCases("zh_Hant_HK", one, two, three, four, results);
+}
+
 // Formatting in Russian.
 // "\\u0438" is used before the last element, and all elements up to (but not including) the penultimate are followed by a comma.
 void ListFormatterTest::TestRussian() {
@@ -181,7 +227,7 @@ void ListFormatterTest::TestMalayalam() {
 void ListFormatterTest::TestZulu() {
     UnicodeString results[4] = {
         one,
-        "I-" + one + " ne-" + two,
+        one + " ne-" + two,
         one + ", " + two + ", ne-" + three,
         one + ", " + two + ", " + three + ", ne-" + four
     };
@@ -227,6 +273,9 @@ void ListFormatterTest::runIndexedTest(int32_t index, UBool exec,
         case 6: name = "TestZulu"; if (exec) TestZulu(); break;
         case 7: name = "TestOutOfOrderPatterns"; if (exec) TestOutOfOrderPatterns(); break;
         case 8: name = "Test9946"; if (exec) Test9946(); break;
+        case 9: name = "TestEnglishGB"; if (exec) TestEnglishGB(); break;
+        case 10: name = "TestNynorsk"; if (exec) TestNynorsk(); break;
+        case 11: name = "TestChineseTradHK"; if (exec) TestChineseTradHK(); break;
 
         default: name = ""; break;
     }