diff options
author | android-build-prod (mdb) <android-build-team-robot@google.com> | 2019-08-09 23:03:21 +0000 |
---|---|---|
committer | android-build-prod (mdb) <android-build-team-robot@google.com> | 2019-08-09 23:03:21 +0000 |
commit | be4a71f8e5441f4a7e2b1341646f29ded616d651 (patch) | |
tree | 164812e60503093de0481f6abbeff2e4dc2b1eb6 | |
parent | 81cc5873bdf549e939d9c6d632ad244c73457e32 (diff) | |
parent | 92a9ce5ff38cb68eb0036530382c4f2501b2ef23 (diff) | |
download | icu-oreo-vts-release.tar.gz |
Snap for 5792809 from 92a9ce5ff38cb68eb0036530382c4f2501b2ef23 to oreo-vts-releaseandroid-vts-8.0_r13android-vts-8.0_r12oreo-vts-release
Change-Id: I11ed97c65450a6beeeae37241dc7cbea5cb3b0df
-rw-r--r-- | android_icu4j/src/main/tests/android/icu/dev/data/testdata/format.res | bin | 5712 -> 5696 bytes | |||
-rw-r--r-- | android_icu4j/src/main/tests/android/icu/dev/data/testdata/structLocale.res | bin | 162752 -> 162768 bytes | |||
-rw-r--r-- | android_icu4j/src/main/tests/android/icu/dev/test/calendar/JapaneseTest.java | 42 | ||||
-rw-r--r-- | android_icu4j/src/main/tests/android/icu/dev/test/format/DataDrivenFormatTest.java | 9 | ||||
-rw-r--r-- | icu4c/source/test/intltest/incaltst.cpp | 55 | ||||
-rw-r--r-- | icu4c/source/test/intltest/incaltst.h | 3 | ||||
-rw-r--r-- | icu4c/source/test/testdata/format.txt | 10 | ||||
-rw-r--r-- | icu4c/source/test/testdata/structLocale.txt | 3 | ||||
-rwxr-xr-x | icu4j/main/shared/data/testdata.jar | bin | 812434 -> 812440 bytes | |||
-rw-r--r-- | icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/JapaneseTest.java | 42 | ||||
-rw-r--r-- | icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DataDrivenFormatTest.java | 9 |
11 files changed, 147 insertions, 26 deletions
diff --git a/android_icu4j/src/main/tests/android/icu/dev/data/testdata/format.res b/android_icu4j/src/main/tests/android/icu/dev/data/testdata/format.res Binary files differindex 61e45b8a3..b6e62c2a7 100644 --- a/android_icu4j/src/main/tests/android/icu/dev/data/testdata/format.res +++ b/android_icu4j/src/main/tests/android/icu/dev/data/testdata/format.res diff --git a/android_icu4j/src/main/tests/android/icu/dev/data/testdata/structLocale.res b/android_icu4j/src/main/tests/android/icu/dev/data/testdata/structLocale.res Binary files differindex 38f009286..ce139ddaf 100644 --- a/android_icu4j/src/main/tests/android/icu/dev/data/testdata/structLocale.res +++ b/android_icu4j/src/main/tests/android/icu/dev/data/testdata/structLocale.res diff --git a/android_icu4j/src/main/tests/android/icu/dev/test/calendar/JapaneseTest.java b/android_icu4j/src/main/tests/android/icu/dev/test/calendar/JapaneseTest.java index eab03a05f..f819c7024 100644 --- a/android_icu4j/src/main/tests/android/icu/dev/test/calendar/JapaneseTest.java +++ b/android_icu4j/src/main/tests/android/icu/dev/test/calendar/JapaneseTest.java @@ -154,9 +154,9 @@ public class JapaneseTest extends CalendarTestFmwk { Calendar cal = new JapaneseCalendar(loc); DateFormat enjformat = cal.getDateTimeFormat(0,0,new ULocale("en_JP@calendar=japanese")); DateFormat format = cal.getDateTimeFormat(0,0,loc); - ((SimpleDateFormat)format).applyPattern("y.M.d"); // Note: just 'y' doesn't work here. + ((SimpleDateFormat)format).applyPattern("y/M/d"); // Note: just 'y' doesn't work here. ParsePosition pos = new ParsePosition(0); - Date aDate = format.parse("1.1.9", pos); // after the start of heisei accession. Jan 1, 1H wouldn't work because it is actually showa 64 + Date aDate = format.parse("1/5/9", pos); // after the start of Reiwa accession. Jan 1, R1 wouldn't work because it is actually Heisei 31 String inEn = enjformat.format(aDate); cal.clear(); @@ -165,7 +165,7 @@ public class JapaneseTest extends CalendarTestFmwk { int gotEra = cal.get(Calendar.ERA); int expectYear = 1; - int expectEra = JapaneseCalendar.CURRENT_ERA; + int expectEra = JapaneseCalendar.CURRENT_ERA; // Reiwa if((gotYear != expectYear) || (gotEra != expectEra)) { errln("Expected year " + expectYear + ", era " + expectEra +", but got year " + gotYear + " and era " + gotEra + ", == " + inEn); @@ -173,7 +173,7 @@ public class JapaneseTest extends CalendarTestFmwk { logln("Got year " + gotYear + " and era " + gotEra + ", == " + inEn); } - // Test parse with missing era (should default to current era, heisei) + // Test parse with missing era (should default to current era) // Test parse with incomplete information logln("Testing parse w/ just year..."); Calendar cal2 = new JapaneseCalendar(loc); @@ -197,7 +197,7 @@ public class JapaneseTest extends CalendarTestFmwk { gotYear = cal2.get(Calendar.YEAR); gotEra = cal2.get(Calendar.ERA); expectYear = 1; - expectEra = JapaneseCalendar.CURRENT_ERA; + expectEra = JapaneseCalendar.CURRENT_ERA; // Reiwa if((gotYear != 1) || (gotEra != expectEra)) { errln("parse "+ samplestr + " of 'y' as Japanese Calendar, expected year " + expectYear + " and era " + expectEra + ", but got year " + gotYear + " and era " + gotEra + " (Gregorian:" + str +")"); @@ -379,5 +379,37 @@ public class JapaneseTest extends CalendarTestFmwk { doLimitsTest(jcal, null, cal.getTime()); doTheoreticalLimitsTest(jcal, true); } + + @Test + public void TestHeiseiToReiwa() { + Calendar cal = Calendar.getInstance(); + cal.set(2019, Calendar.APRIL, 29); + + DateFormat jfmt = DateFormat.getDateInstance(DateFormat.LONG, new ULocale("ja@calendar=japanese")); + + // Android-changed: Old Android releases can optionally support the new Japanese era. + boolean isCurrentHeisei = JapaneseCalendar.CURRENT_ERA == JapaneseCalendar.HEISEI; + final String[] EXPECTED_FORMAT = new String[] { + "\u5E73\u621031\u5E744\u670829\u65E5", // Heisei 31 April 29 + "\u5E73\u621031\u5E744\u670830\u65E5", // Heisei 31 April 30 + isCurrentHeisei + ? "\u5E73\u621031\u5E745\u67081\u65E5" // Heisei 31 May 1 + : "\u4EE4\u548C1\u5E745\u67081\u65E5", // Reiwa 1 May 1 + isCurrentHeisei + ? "\u5E73\u621031\u5E745\u67082\u65E5" // Heisei 31 May 2 + : "\u4EE4\u548C1\u5E745\u67082\u65E5", // Reiwa 1 May 2 + }; + + for (int i = 0; i < EXPECTED_FORMAT.length; i++) { + Date d = cal.getTime(); + String dateStr = jfmt.format(d); + if (!EXPECTED_FORMAT[i].equals(dateStr)) { + errln("Formatting year:" + cal.get(Calendar.YEAR) + " month:" + (cal.get(Calendar.MONTH) + 1) + + " day:" + cal.get(Calendar.DATE) + " - expected: " + EXPECTED_FORMAT[i] + + " / actual: " + dateStr); + } + cal.add(Calendar.DATE, 1); + } + } } diff --git a/android_icu4j/src/main/tests/android/icu/dev/test/format/DataDrivenFormatTest.java b/android_icu4j/src/main/tests/android/icu/dev/test/format/DataDrivenFormatTest.java index 2755bccb7..5789e757e 100644 --- a/android_icu4j/src/main/tests/android/icu/dev/test/format/DataDrivenFormatTest.java +++ b/android_icu4j/src/main/tests/android/icu/dev/test/format/DataDrivenFormatTest.java @@ -29,6 +29,7 @@ import android.icu.dev.test.util.DateTimeStyleSet; import android.icu.text.DateFormat; import android.icu.text.SimpleDateFormat; import android.icu.util.Calendar; +import android.icu.util.JapaneseCalendar; import android.icu.util.TimeZone; import android.icu.util.ULocale; @@ -100,6 +101,14 @@ public class DataDrivenFormatTest extends TestFmwk { String spec = currentCase.getString("spec"); String date = currentCase.getString("date"); String str = currentCase.getString("str"); + + // Android-changed: Old Android releases can optionally support the new Japanese era. + // Note that the value of CURRENT_ERA comes from the system image, the string "Reiwa" + // comes from test side binary resource file. + if (JapaneseCalendar.CURRENT_ERA == JapaneseCalendar.HEISEI + && "TestConsistentPivot".equals(testData.getName())) { + str = str.replace("Reiwa", "Heisei"); + } Date fromDate = null; boolean useDate = false; diff --git a/icu4c/source/test/intltest/incaltst.cpp b/icu4c/source/test/intltest/incaltst.cpp index a6b5204c9..8935b3322 100644 --- a/icu4c/source/test/intltest/incaltst.cpp +++ b/icu4c/source/test/intltest/incaltst.cpp @@ -77,6 +77,7 @@ void IntlCalendarTest::runIndexedTest( int32_t index, UBool exec, const char* &n CASE(7,TestPersian); CASE(8,TestPersianFormat); CASE(9,TestTaiwan); + CASE(10,TestJapaneseHeiseiToReiwa); default: name = ""; break; } } @@ -626,23 +627,23 @@ void IntlCalendarTest::TestJapanese3860() // Test simple parse/format with adopt UDate aDate = 0; - // Test parse with missing era (should default to current era, heisei) + // Test parse with missing era (should default to current era) // Test parse with incomplete information logln("Testing parse w/ missing era..."); - SimpleDateFormat *fmt = new SimpleDateFormat(UnicodeString("y.M.d"), Locale("ja_JP@calendar=japanese"), status); + SimpleDateFormat *fmt = new SimpleDateFormat(UnicodeString("y/M/d"), Locale("ja_JP@calendar=japanese"), status); CHECK(status, "creating date format instance"); if(!fmt) { errln("Coudln't create en_US instance"); } else { UErrorCode s2 = U_ZERO_ERROR; cal2->clear(); - UnicodeString samplestr("1.1.9"); + UnicodeString samplestr("1/5/9"); logln(UnicodeString() + "Test Year: " + samplestr); aDate = fmt->parse(samplestr, s2); ParsePosition pp=0; fmt->parse(samplestr, *cal2, pp); - CHECK(s2, "parsing the 1.1.9 string"); - logln("*cal2 after 119 parse:"); + CHECK(s2, "parsing the 1/5/9 string"); + logln("*cal2 after 159 parse:"); str.remove(); fmt2->format(aDate, str); logln(UnicodeString() + "as Gregorian Calendar: " + str); @@ -653,7 +654,7 @@ void IntlCalendarTest::TestJapanese3860() int32_t expectYear = 1; int32_t expectEra = JapaneseCalendar::getCurrentEra(); if((gotYear!=1) || (gotEra != expectEra)) { - errln(UnicodeString("parse "+samplestr+" of 'y.m.d' as Japanese Calendar, expected year ") + expectYear + + errln(UnicodeString("parse "+samplestr+" of 'y/m/d' as Japanese Calendar, expected year ") + expectYear + UnicodeString(" and era ") + expectEra +", but got year " + gotYear + " and era " + gotEra + " (Gregorian:" + str +")"); } else { logln(UnicodeString() + " year: " + gotYear + ", era: " + gotEra); @@ -666,7 +667,7 @@ void IntlCalendarTest::TestJapanese3860() // Test simple parse/format with adopt UDate aDate = 0; - // Test parse with missing era (should default to current era, heisei) + // Test parse with missing era (should default to current era) // Test parse with incomplete information logln("Testing parse w/ just year..."); SimpleDateFormat *fmt = new SimpleDateFormat(UnicodeString("y"), Locale("ja_JP@calendar=japanese"), status); @@ -678,7 +679,7 @@ void IntlCalendarTest::TestJapanese3860() cal2->clear(); UnicodeString samplestr("1"); logln(UnicodeString() + "Test Year: " + samplestr); - aDate = fmt->parse(samplestr, s2); + aDate = fmt->parse(samplestr, s2); // Should be parsed as the first day of the current era ParsePosition pp=0; fmt->parse(samplestr, *cal2, pp); CHECK(s2, "parsing the 1 string"); @@ -691,7 +692,7 @@ void IntlCalendarTest::TestJapanese3860() int32_t gotYear = cal2->get(UCAL_YEAR, s2); int32_t gotEra = cal2->get(UCAL_ERA, s2); int32_t expectYear = 1; - int32_t expectEra = 235; //JapaneseCalendar::kCurrentEra; + int32_t expectEra = JapaneseCalendar::getCurrentEra(); if((gotYear!=1) || (gotEra != expectEra)) { errln(UnicodeString("parse "+samplestr+" of 'y' as Japanese Calendar, expected year ") + expectYear + UnicodeString(" and era ") + expectEra +", but got year " + gotYear + " and era " + gotEra + " (Gregorian:" + str +")"); @@ -700,13 +701,47 @@ void IntlCalendarTest::TestJapanese3860() } delete fmt; } - } + } delete cal2; delete cal; delete fmt2; } +void IntlCalendarTest::TestJapaneseHeiseiToReiwa() { + Calendar *cal; + UErrorCode status = U_ZERO_ERROR; + cal = Calendar::createInstance(status); + CHECK(status, UnicodeString("Creating default Gregorian Calendar")); + cal->set(2019, UCAL_APRIL, 29); + + DateFormat *jfmt = DateFormat::createDateInstance(DateFormat::LONG, "ja@calendar=japanese"); + CHECK(status, UnicodeString("Creating date format ja@calendar=japanese")) + + const char* EXPECTED_FORMAT[4] = { + "\\u5E73\\u621031\\u5E744\\u670829\\u65E5", // Heisei 31 April 29 + "\\u5E73\\u621031\\u5E744\\u670830\\u65E5", // Heisei 31 April 30 + "\\u4EE4\\u548c1\\u5E745\\u67081\\u65E5", // Reiwa 1 May 1 + "\\u4EE4\\u548c1\\u5E745\\u67082\\u65E5" // Reiwa 1 May 2 + }; + + for (int32_t i = 0; i < 4; i++) { + UnicodeString dateStr; + UDate d = cal->getTime(status); + CHECK(status, UnicodeString("Get test date")); + jfmt->format(d, dateStr); + UnicodeString expected(UnicodeString(EXPECTED_FORMAT[i], -1, US_INV).unescape()); + if (expected.compare(dateStr) != 0) { + errln(UnicodeString("Formatting year:") + cal->get(UCAL_YEAR, status) + " month:" + + cal->get(UCAL_MONTH, status) + " day:" + (cal->get(UCAL_DATE, status) + 1) + + " - expected: " + expected + " / actual: " + dateStr); + } + cal->add(UCAL_DATE, 1, status); + CHECK(status, UnicodeString("Add 1 day")); + } + delete jfmt; + delete cal; +} diff --git a/icu4c/source/test/intltest/incaltst.h b/icu4c/source/test/intltest/incaltst.h index 029236634..e867e2266 100644 --- a/icu4c/source/test/intltest/incaltst.h +++ b/icu4c/source/test/intltest/incaltst.h @@ -34,7 +34,8 @@ public: void TestJapanese(void); void TestJapaneseFormat(void); void TestJapanese3860(void); - + void TestJapaneseHeiseiToReiwa(void); + void TestPersian(void); void TestPersianFormat(void); diff --git a/icu4c/source/test/testdata/format.txt b/icu4c/source/test/testdata/format.txt index c0364e2c1..c598ade6a 100644 --- a/icu4c/source/test/testdata/format.txt +++ b/icu4c/source/test/testdata/format.txt @@ -494,35 +494,35 @@ format:table(nofallback) { "", "PATTERN=G y", "YEAR=8", - "Heisei 8" + "Reiwa 8" }, { "en_US@calendar=japanese", "", "PATTERN=G yy", "YEAR=8", - "Heisei 08" + "Reiwa 08" }, { "en_US@calendar=japanese", "", "PATTERN=G yyy", "YEAR=8", - "Heisei 008" + "Reiwa 008" }, { "en_US@calendar=japanese", "", "PATTERN=G yyyy", "YEAR=8", - "Heisei 0008" + "Reiwa 0008" }, { "en_US@calendar=japanese", "", "PATTERN=G yyyyy", "YEAR=8", - "Heisei 00008" + "Reiwa 00008" }, } diff --git a/icu4c/source/test/testdata/structLocale.txt b/icu4c/source/test/testdata/structLocale.txt index f0de36c7c..0bed0582d 100644 --- a/icu4c/source/test/testdata/structLocale.txt +++ b/icu4c/source/test/testdata/structLocale.txt @@ -25360,6 +25360,7 @@ structLocale:table(nofallback){ "", "", "", + "", } wide{ "", @@ -25598,6 +25599,7 @@ structLocale:table(nofallback){ "", "", "", + "", } narrow{ "", @@ -25836,6 +25838,7 @@ structLocale:table(nofallback){ "", "", "", + "", } } intervalFormats{ diff --git a/icu4j/main/shared/data/testdata.jar b/icu4j/main/shared/data/testdata.jar Binary files differindex 4d74c9f6c..0147195e1 100755 --- a/icu4j/main/shared/data/testdata.jar +++ b/icu4j/main/shared/data/testdata.jar diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/JapaneseTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/JapaneseTest.java index 34f959564..5283a39d3 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/JapaneseTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/JapaneseTest.java @@ -151,9 +151,9 @@ public class JapaneseTest extends CalendarTestFmwk { Calendar cal = new JapaneseCalendar(loc); DateFormat enjformat = cal.getDateTimeFormat(0,0,new ULocale("en_JP@calendar=japanese")); DateFormat format = cal.getDateTimeFormat(0,0,loc); - ((SimpleDateFormat)format).applyPattern("y.M.d"); // Note: just 'y' doesn't work here. + ((SimpleDateFormat)format).applyPattern("y/M/d"); // Note: just 'y' doesn't work here. ParsePosition pos = new ParsePosition(0); - Date aDate = format.parse("1.1.9", pos); // after the start of heisei accession. Jan 1, 1H wouldn't work because it is actually showa 64 + Date aDate = format.parse("1/5/9", pos); // after the start of Reiwa accession. Jan 1, R1 wouldn't work because it is actually Heisei 31 String inEn = enjformat.format(aDate); cal.clear(); @@ -162,7 +162,7 @@ public class JapaneseTest extends CalendarTestFmwk { int gotEra = cal.get(Calendar.ERA); int expectYear = 1; - int expectEra = JapaneseCalendar.CURRENT_ERA; + int expectEra = JapaneseCalendar.CURRENT_ERA; // Reiwa if((gotYear != expectYear) || (gotEra != expectEra)) { errln("Expected year " + expectYear + ", era " + expectEra +", but got year " + gotYear + " and era " + gotEra + ", == " + inEn); @@ -170,7 +170,7 @@ public class JapaneseTest extends CalendarTestFmwk { logln("Got year " + gotYear + " and era " + gotEra + ", == " + inEn); } - // Test parse with missing era (should default to current era, heisei) + // Test parse with missing era (should default to current era) // Test parse with incomplete information logln("Testing parse w/ just year..."); Calendar cal2 = new JapaneseCalendar(loc); @@ -194,7 +194,7 @@ public class JapaneseTest extends CalendarTestFmwk { gotYear = cal2.get(Calendar.YEAR); gotEra = cal2.get(Calendar.ERA); expectYear = 1; - expectEra = JapaneseCalendar.CURRENT_ERA; + expectEra = JapaneseCalendar.CURRENT_ERA; // Reiwa if((gotYear != 1) || (gotEra != expectEra)) { errln("parse "+ samplestr + " of 'y' as Japanese Calendar, expected year " + expectYear + " and era " + expectEra + ", but got year " + gotYear + " and era " + gotEra + " (Gregorian:" + str +")"); @@ -376,5 +376,37 @@ public class JapaneseTest extends CalendarTestFmwk { doLimitsTest(jcal, null, cal.getTime()); doTheoreticalLimitsTest(jcal, true); } + + @Test + public void TestHeiseiToReiwa() { + Calendar cal = Calendar.getInstance(); + cal.set(2019, Calendar.APRIL, 29); + + DateFormat jfmt = DateFormat.getDateInstance(DateFormat.LONG, new ULocale("ja@calendar=japanese")); + + // Android-changed: Old Android releases can optionally support the new Japanese era. + boolean isCurrentHeisei = JapaneseCalendar.CURRENT_ERA == JapaneseCalendar.HEISEI; + final String[] EXPECTED_FORMAT = new String[] { + "\u5E73\u621031\u5E744\u670829\u65E5", // Heisei 31 April 29 + "\u5E73\u621031\u5E744\u670830\u65E5", // Heisei 31 April 30 + isCurrentHeisei + ? "\u5E73\u621031\u5E745\u67081\u65E5" // Heisei 31 May 1 + : "\u4EE4\u548C1\u5E745\u67081\u65E5", // Reiwa 1 May 1 + isCurrentHeisei + ? "\u5E73\u621031\u5E745\u67082\u65E5" // Heisei 31 May 2 + : "\u4EE4\u548C1\u5E745\u67082\u65E5", // Reiwa 1 May 2 + }; + + for (int i = 0; i < EXPECTED_FORMAT.length; i++) { + Date d = cal.getTime(); + String dateStr = jfmt.format(d); + if (!EXPECTED_FORMAT[i].equals(dateStr)) { + errln("Formatting year:" + cal.get(Calendar.YEAR) + " month:" + (cal.get(Calendar.MONTH) + 1) + + " day:" + cal.get(Calendar.DATE) + " - expected: " + EXPECTED_FORMAT[i] + + " / actual: " + dateStr); + } + cal.add(Calendar.DATE, 1); + } + } } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DataDrivenFormatTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DataDrivenFormatTest.java index 91cf2eeda..60b40a266 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DataDrivenFormatTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DataDrivenFormatTest.java @@ -28,6 +28,7 @@ import com.ibm.icu.dev.test.util.DateTimeStyleSet; import com.ibm.icu.text.DateFormat; import com.ibm.icu.text.SimpleDateFormat; import com.ibm.icu.util.Calendar; +import com.ibm.icu.util.JapaneseCalendar; import com.ibm.icu.util.TimeZone; import com.ibm.icu.util.ULocale; @@ -97,6 +98,14 @@ public class DataDrivenFormatTest extends TestFmwk { String spec = currentCase.getString("spec"); String date = currentCase.getString("date"); String str = currentCase.getString("str"); + + // Android-changed: Old Android releases can optionally support the new Japanese era. + // Note that the value of CURRENT_ERA comes from the system image, the string "Reiwa" + // comes from test side binary resource file. + if (JapaneseCalendar.CURRENT_ERA == JapaneseCalendar.HEISEI + && "TestConsistentPivot".equals(testData.getName())) { + str = str.replace("Reiwa", "Heisei"); + } Date fromDate = null; boolean useDate = false; |