+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
*
-* Copyright (C) 2012-2014, International Business Machines
+* Copyright (C) 2012-2016, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* file name: listformattertest.cpp
-* encoding: US-ASCII
+* encoding: UTF-8
* tab size: 8 (not used)
* indentation:4
*
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() {
void ListFormatterTest::TestZulu() {
UnicodeString results[4] = {
one,
- "I-" + one + " ne-" + two,
+ one + " ne-" + two,
one + ", " + two + ", ne-" + three,
one + ", " + two + ", " + three + ", ne-" + four
};
four + " in the last after " + three + " after " + two + " after the first " + one
};
+ UErrorCode errorCode = U_ZERO_ERROR;
ListFormatData data("{1} after {0}", "{1} after the first {0}",
"{1} after {0}", "{1} in the last after {0}");
- ListFormatter formatter(data);
+ ListFormatter formatter(data, errorCode);
UnicodeString input1[] = {one};
CheckFormatting(&formatter, input1, 1, results[0]);
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;
}