From 736757aced18dbc761a8a35a23cbe490ceeaf8c1 Mon Sep 17 00:00:00 2001 From: Frank Tang Date: Thu, 14 Feb 2019 15:24:15 -0800 Subject: [PATCH] ICU-20407 hy-arevela/hy-arevmda can. into hy / hyw --- icu4c/source/common/uloc.cpp | 2 ++ icu4c/source/test/cintltst/cloctst.c | 4 +--- icu4c/source/test/intltest/loctest.cpp | 19 +++++++++++++++++++ icu4c/source/test/intltest/loctest.h | 2 ++ .../core/src/com/ibm/icu/util/ULocale.java | 2 ++ .../ibm/icu/dev/test/util/ULocaleTest.java | 8 ++++++++ 6 files changed, 34 insertions(+), 3 deletions(-) diff --git a/icu4c/source/common/uloc.cpp b/icu4c/source/common/uloc.cpp index a4902effae5..a057491742e 100644 --- a/icu4c/source/common/uloc.cpp +++ b/icu4c/source/common/uloc.cpp @@ -465,6 +465,8 @@ typedef struct CanonicalizationMap { */ static const CanonicalizationMap CANONICALIZE_MAP[] = { { "art_LOJBAN", "jbo" }, /* registered name */ + { "hy__AREVELA", "hy" }, /* Registered IANA variant */ + { "hy__AREVMDA", "hyw" }, /* Registered IANA variant */ { "zh_GAN", "gan" }, /* registered name */ { "zh_GUOYU", "zh" }, /* registered name */ { "zh_HAKKA", "hak" }, /* registered name */ diff --git a/icu4c/source/test/cintltst/cloctst.c b/icu4c/source/test/cintltst/cloctst.c index 6aec8ef47a5..09de64c874e 100644 --- a/icu4c/source/test/cintltst/cloctst.c +++ b/icu4c/source/test/cintltst/cloctst.c @@ -423,9 +423,7 @@ static void TestPrefixes() { {"i-hakka", "", "CN", "", "i-hakka_CN", "i-hakka_CN", NULL}, {"i-hakka", "", "MX", "", "I-hakka_MX", "i-hakka_MX", NULL}, {"x-klingon", "", "US", "SANJOSE", "X-KLINGON_us_SANJOSE", "x-klingon_US_SANJOSE", NULL}, - - {"hy", "", "", "AREVMDA", "hy_AREVMDA", "hy__AREVMDA", NULL}, - + {"hy", "", "", "AREVMDA", "hy_AREVMDA", "hy__AREVMDA", "hyw"}, {"de", "", "", "1901", "de-1901", "de__1901", NULL}, {"mr", "", "", "", "mr.utf8", "mr.utf8", "mr"}, {"de", "", "TV", "", "de-tv.koi8r", "de_TV.koi8r", "de_TV"}, diff --git a/icu4c/source/test/intltest/loctest.cpp b/icu4c/source/test/intltest/loctest.cpp index 3e0c5cbf585..e3de596b2ec 100644 --- a/icu4c/source/test/intltest/loctest.cpp +++ b/icu4c/source/test/intltest/loctest.cpp @@ -252,6 +252,7 @@ void LocaleTest::runIndexedTest( int32_t index, UBool exec, const char* &name, c TESTCASE_AUTO(TestToLanguageTag); TESTCASE_AUTO(TestMoveAssign); TESTCASE_AUTO(TestMoveCtor); + TESTCASE_AUTO(TestBug20407iVariantPreferredValue); TESTCASE_AUTO(TestBug13417VeryLongLanguageTag); TESTCASE_AUTO(TestBug11053UnderlineTimeZone); TESTCASE_AUTO_END; @@ -3163,6 +3164,24 @@ void LocaleTest::TestMoveCtor() { assertEquals("bogus", l7.isBogus(), l8.isBogus()); } +void LocaleTest::TestBug20407iVariantPreferredValue() { + IcuTestErrorCode status(*this, "TestBug20407iVariantPreferredValue()"); + + Locale l = Locale::forLanguageTag("hy-arevela", status); + status.errIfFailureAndReset("hy-arevela fail"); + assertTrue("!l.isBogus()", !l.isBogus()); + + std::string result = l.toLanguageTag(status); + assertEquals(l.getName(), "hy", result.c_str()); + + l = Locale::forLanguageTag("hy-arevmda", status); + status.errIfFailureAndReset("hy-arevmda"); + assertTrue("!l.isBogus()", !l.isBogus()); + + result = l.toLanguageTag(status); + assertEquals(l.getName(), "hyw", result.c_str()); +} + void LocaleTest::TestBug13417VeryLongLanguageTag() { IcuTestErrorCode status(*this, "TestBug13417VeryLongLanguageTag()"); diff --git a/icu4c/source/test/intltest/loctest.h b/icu4c/source/test/intltest/loctest.h index 1ea9f2d6dfd..bebb26cebca 100644 --- a/icu4c/source/test/intltest/loctest.h +++ b/icu4c/source/test/intltest/loctest.h @@ -124,6 +124,8 @@ public: void TestMoveAssign(); void TestMoveCtor(); + void TestBug20407iVariantPreferredValue(); + void TestBug13417VeryLongLanguageTag(); void TestBug11053UnderlineTimeZone(); diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java b/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java index 54827e38e53..785e790684f 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java @@ -342,6 +342,8 @@ public final class ULocale implements Serializable, Comparable { { "de_1906", "de__1906" }, /* registered name */ { "en_BOONT", "en__BOONT" }, /* registered name */ { "en_SCOUSE", "en__SCOUSE" }, /* registered name */ + { "hy__AREVELA", "hy", null, null }, /* Registered IANA variant */ + { "hy__AREVMDA", "hyw", null, null }, /* Registered IANA variant */ { "sl_ROZAJ", "sl__ROZAJ" }, /* registered name */ { "zh_GAN", "zh__GAN" }, /* registered name */ { "zh_GUOYU", "zh" }, /* registered name */ diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java index 5b657c8f8ee..0d5365727a6 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java @@ -1489,6 +1489,14 @@ public class ULocaleTest extends TestFmwk { assertEquals("foobar", target, name); } + @Test + public void TestBug20407iVariantPreferredValue() { + ULocale uloc = ULocale.createCanonical("hy-arevela"); + assertEquals("getName()", "hy", uloc.getName()); + uloc = ULocale.createCanonical("hy-arevmda"); + assertEquals("getName()", "hyw", uloc.getName()); + } + private void initHashtable() { h[0] = new HashMap(); h[1] = new HashMap(); -- 2.40.0