ICU-2943 test keyword support in calendar
X-SVN-Rev: 13698
This commit is contained in:
parent
8b34cb2ebc
commit
620a38e824
@ -1311,7 +1311,7 @@ void CalendarRegressionTest::test4118384()
|
||||
}
|
||||
|
||||
delete cal;
|
||||
cal = Calendar::createInstance(Locale("th_TH_TRADITIONAL"),status);
|
||||
cal = Calendar::createInstance(Locale("th_TH@calendar=buddhist"),status);
|
||||
// test deprecated functions
|
||||
if (cal->getLeastMaximum(Calendar::HOUR) != 11 ||
|
||||
cal->getMaximum(Calendar::HOUR) != 11) {
|
||||
@ -1325,7 +1325,7 @@ void CalendarRegressionTest::test4118384()
|
||||
|
||||
delete cal;
|
||||
// test deprecated functions
|
||||
cal = Calendar::createInstance(Locale("ja_JP_TRADITIONAL"),status);
|
||||
cal = Calendar::createInstance(Locale("ja_JP@calendar=japanese"),status);
|
||||
if (cal->getLeastMaximum(Calendar::HOUR) != 11 ||
|
||||
cal->getMaximum(Calendar::HOUR) != 11) {
|
||||
errln("Fail: Japanese:[deprecated functions] maximum of HOUR field should be 11\n");
|
||||
@ -2511,7 +2511,7 @@ CalendarRegressionTest::makeDate(int32_t y, int32_t m, int32_t d,
|
||||
void CalendarRegressionTest::TestDeprecates(void)
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
Calendar *c1 = Calendar::createInstance("ja_JP_TRADITIONAL",status);
|
||||
Calendar *c1 = Calendar::createInstance("ja_JP@calendar=japanese",status);
|
||||
Calendar *c2 = Calendar::createInstance("ja_JP_TRADITIONAL",status);
|
||||
|
||||
if(!c1 || !c2 || U_FAILURE(status)) {
|
||||
@ -2548,7 +2548,7 @@ void CalendarRegressionTest::TestDeprecates(void)
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
c1 = Calendar::createInstance("th_TH_TRADITIONAL",status);
|
||||
c2 = Calendar::createInstance("th_TH_TRADITIONAL",status);
|
||||
c2 = Calendar::createInstance("th_TH@calendar=buddhist",status);
|
||||
|
||||
if(!c1 || !c2 || U_FAILURE(status)) {
|
||||
errln("Couldn't create calendars for add of HOUR");
|
||||
|
@ -88,12 +88,22 @@ IntlCalendarTest::TestTypes()
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
int j;
|
||||
const char *locs [40] = { "en_US_VALLEYGIRL",
|
||||
"en_US_VALLEYGIRL@collation=phonebook;calendar=japanese",
|
||||
"en_US_VALLEYGIRL@collation=phonebook;calendar=gregorian",
|
||||
"ja_JP@calendar=japanese",
|
||||
"th_TH@calendar=buddhist",
|
||||
"ja_JP_TRADITIONAL",
|
||||
"th_TH_TRADITIONAL",
|
||||
"th_TH_TRADITIONAL@calendar=gregorian",
|
||||
"en_US", NULL };
|
||||
const char *types[40] = { "gregorian",
|
||||
"japanese",
|
||||
"gregorian",
|
||||
"japanese",
|
||||
"buddhist",
|
||||
"japanese",
|
||||
"buddhist",
|
||||
"gregorian",
|
||||
"gregorian", NULL };
|
||||
|
||||
for(j=0;locs[j];j++) {
|
||||
@ -253,8 +263,8 @@ void IntlCalendarTest::TestBuddhist() {
|
||||
};
|
||||
Calendar *cal;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
cal = Calendar::createInstance("th_TH_TRADITIONAL", status);
|
||||
CHECK(status, UnicodeString("Creating th_TH_TRADITIONAL calendar"));
|
||||
cal = Calendar::createInstance("th_TH@calendar=buddhist", status);
|
||||
CHECK(status, UnicodeString("Creating th_TH@calendar=buddhist calendar"));
|
||||
|
||||
// Sanity check the calendar
|
||||
UDate timeB = Calendar::getNow();
|
||||
@ -305,8 +315,8 @@ void IntlCalendarTest::TestJapanese() {
|
||||
|
||||
Calendar *cal;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
cal = Calendar::createInstance("ja_JP_TRADITIONAL", status);
|
||||
CHECK(status, UnicodeString("Creating ja_JP_TRADITIONAL calendar"));
|
||||
cal = Calendar::createInstance("ja_JP@calendar=japanese", status);
|
||||
CHECK(status, UnicodeString("Creating ja_JP@calendar=japanese calendar"));
|
||||
// Sanity check the calendar
|
||||
UDate timeB = Calendar::getNow();
|
||||
UDate timeCal = cal->getTime(status);
|
||||
@ -323,24 +333,22 @@ void IntlCalendarTest::TestJapanese() {
|
||||
void IntlCalendarTest::TestBuddhistFormat() {
|
||||
Calendar *cal;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
cal = Calendar::createInstance("th_TH_TRADITIONAL", status);
|
||||
CHECK(status, UnicodeString("Creating th_TH_TRADITIONAL calendar"));
|
||||
|
||||
// Test simple parse/format with adopt
|
||||
|
||||
// First, a contrived english test..
|
||||
UDate aDate = 999932400000.0;
|
||||
SimpleDateFormat *fmt = new SimpleDateFormat(UnicodeString("MMMM d, yyyy G"), Locale("en_US"), status);
|
||||
SimpleDateFormat *fmt = new SimpleDateFormat(UnicodeString("MMMM d, yyyy G"), Locale("en_US@calendar=buddhist"), status);
|
||||
CHECK(status, "creating date format instance");
|
||||
SimpleDateFormat *fmt2 = new SimpleDateFormat(UnicodeString("MMMM d, yyyy G"), Locale("en_US@calendar=gregorian"), status);
|
||||
CHECK(status, "creating gregorian date format instance");
|
||||
if(!fmt) {
|
||||
errln("Coudln't create en_US instance");
|
||||
} else {
|
||||
UnicodeString str;
|
||||
fmt->format(aDate, str);
|
||||
fmt2->format(aDate, str);
|
||||
logln(UnicodeString() + "Test Date: " + str);
|
||||
str.remove();
|
||||
fmt->adoptCalendar(cal);
|
||||
cal = NULL;
|
||||
fmt->format(aDate, str);
|
||||
logln(UnicodeString() + "as Buddhist Calendar: " + escape(str));
|
||||
UnicodeString expected("September 8, 2544 BE");
|
||||
@ -357,7 +365,7 @@ void IntlCalendarTest::TestBuddhistFormat() {
|
||||
}
|
||||
delete fmt;
|
||||
}
|
||||
delete cal;
|
||||
delete fmt2;
|
||||
|
||||
CHECK(status, "Error occured testing Buddhist Calendar in English ");
|
||||
|
||||
@ -367,7 +375,31 @@ void IntlCalendarTest::TestBuddhistFormat() {
|
||||
UnicodeString expect = CharsToUnicodeString("\\u0E27\\u0E31\\u0E19\\u0E40\\u0E2A\\u0E32\\u0E23\\u0E4C\\u0E17\\u0E35\\u0E48"
|
||||
" 8 \\u0E01\\u0E31\\u0e19\\u0e22\\u0e32\\u0e22\\u0e19 \\u0e1e.\\u0e28. 2544");
|
||||
UDate expectDate = 999932400000.0;
|
||||
Locale loc("th_TH_TRADITIONAL");
|
||||
Locale loc("th_TH_TRADITIONAL"); // legacy
|
||||
|
||||
simpleTest(loc, expect, expectDate, status);
|
||||
}
|
||||
{
|
||||
UnicodeString expect = CharsToUnicodeString("\\u0E27\\u0E31\\u0E19\\u0E40\\u0E2A\\u0E32\\u0E23\\u0E4C\\u0E17\\u0E35\\u0E48"
|
||||
" 8 \\u0E01\\u0E31\\u0e19\\u0e22\\u0e32\\u0e22\\u0e19 \\u0e1e.\\u0e28. 2544");
|
||||
UDate expectDate = 999932400000.0;
|
||||
Locale loc("th_TH@calendar=buddhist");
|
||||
|
||||
simpleTest(loc, expect, expectDate, status);
|
||||
}
|
||||
{
|
||||
UnicodeString expect = CharsToUnicodeString("\\u0E27\\u0E31\\u0E19\\u0E40\\u0E2A\\u0E32\\u0E23\\u0E4C\\u0E17\\u0E35\\u0E48"
|
||||
" 8 \\u0E01\\u0E31\\u0e19\\u0e22\\u0e32\\u0e22\\u0e19 \\u0e04.\\u0e28. 2001");
|
||||
UDate expectDate = 999932400000.0;
|
||||
Locale loc("th_TH@calendar=gregorian");
|
||||
|
||||
simpleTest(loc, expect, expectDate, status);
|
||||
}
|
||||
{
|
||||
UnicodeString expect = CharsToUnicodeString("\\u0E27\\u0E31\\u0E19\\u0E40\\u0E2A\\u0E32\\u0E23\\u0E4C\\u0E17\\u0E35\\u0E48"
|
||||
" 8 \\u0E01\\u0E31\\u0e19\\u0e22\\u0e32\\u0e22\\u0e19 \\u0e04.\\u0e28. 2001");
|
||||
UDate expectDate = 999932400000.0;
|
||||
Locale loc("th_TH_TRADITIONAL@calendar=gregorian");
|
||||
|
||||
simpleTest(loc, expect, expectDate, status);
|
||||
}
|
||||
@ -385,17 +417,16 @@ void IntlCalendarTest::TestJapaneseFormat() {
|
||||
// Test simple parse/format with adopt
|
||||
|
||||
UDate aDate = 999932400000.0;
|
||||
SimpleDateFormat *fmt = new SimpleDateFormat(UnicodeString("MMMM d, yy G"), Locale("en_US"), status);
|
||||
SimpleDateFormat *fmt = new SimpleDateFormat(UnicodeString("MMMM d, yy G"), Locale("en_US@calendar=japanese"), status);
|
||||
SimpleDateFormat *fmt2 = new SimpleDateFormat(UnicodeString("MMMM d, yy G"), Locale("en_US@calendar=gregorian"), status);
|
||||
CHECK(status, "creating date format instance");
|
||||
if(!fmt) {
|
||||
errln("Coudln't create en_US instance");
|
||||
} else {
|
||||
UnicodeString str;
|
||||
fmt->format(aDate, str);
|
||||
fmt2->format(aDate, str);
|
||||
logln(UnicodeString() + "Test Date: " + str);
|
||||
str.remove();
|
||||
fmt->adoptCalendar(cal);
|
||||
cal = NULL;
|
||||
fmt->format(aDate, str);
|
||||
logln(UnicodeString() + "as Japanese Calendar: " + str);
|
||||
UnicodeString expected("September 8, 13 Heisei");
|
||||
@ -415,19 +446,19 @@ void IntlCalendarTest::TestJapaneseFormat() {
|
||||
}
|
||||
delete fmt;
|
||||
}
|
||||
delete fmt2;
|
||||
|
||||
// Test parse with incomplete information
|
||||
fmt = new SimpleDateFormat(UnicodeString("G y"), Locale("en_US"), status);
|
||||
fmt = new SimpleDateFormat(UnicodeString("G y"), Locale("en_US@calendar=japanese"), status);
|
||||
aDate = -3197120400000.;
|
||||
CHECK(status, "creating date format instance");
|
||||
if(!fmt) {
|
||||
errln("Coudln't create en_US instance");
|
||||
} else {
|
||||
UnicodeString str;
|
||||
fmt->format(aDate, str);
|
||||
fmt2->format(aDate, str);
|
||||
logln(UnicodeString() + "Test Date: " + str);
|
||||
str.remove();
|
||||
fmt->adoptCalendar(cal2->clone());
|
||||
fmt->format(aDate, str);
|
||||
logln(UnicodeString() + "as Japanese Calendar: " + str);
|
||||
UnicodeString expected("Meiji 1");
|
||||
@ -448,7 +479,6 @@ void IntlCalendarTest::TestJapaneseFormat() {
|
||||
delete fmt;
|
||||
}
|
||||
|
||||
delete cal;
|
||||
delete cal2;
|
||||
CHECK(status, "Error occured");
|
||||
|
||||
@ -456,7 +486,15 @@ void IntlCalendarTest::TestJapaneseFormat() {
|
||||
{
|
||||
UnicodeString expect = CharsToUnicodeString("\\u5e73\\u621013\\u5e749\\u67088\\u65e5\\u571f\\u66dc\\u65e5");
|
||||
UDate expectDate = 999932400000.0; // Testing a recent date
|
||||
Locale loc("ja_JP_TRADITIONAL");
|
||||
Locale loc("ja_JP@calendar=japanese");
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
simpleTest(loc, expect, expectDate, status);
|
||||
}
|
||||
{
|
||||
UnicodeString expect = CharsToUnicodeString("\\u5e73\\u621013\\u5e749\\u67088\\u65e5\\u571f\\u66dc\\u65e5");
|
||||
UDate expectDate = 999932400000.0; // Testing a recent date
|
||||
Locale loc("ja_JP_TRADITIONAL"); // legacy
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
simpleTest(loc, expect, expectDate, status);
|
||||
@ -464,7 +502,7 @@ void IntlCalendarTest::TestJapaneseFormat() {
|
||||
{
|
||||
UnicodeString expect = CharsToUnicodeString("\\u5b89\\u6c385\\u5e747\\u67084\\u65e5\\u6728\\u66dc\\u65e5");
|
||||
UDate expectDate = -6106035600000.0;
|
||||
Locale loc("ja_JP_TRADITIONAL");
|
||||
Locale loc("ja_JP@calendar=japanese");
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
simpleTest(loc, expect, expectDate, status);
|
||||
@ -473,7 +511,7 @@ void IntlCalendarTest::TestJapaneseFormat() {
|
||||
{ // Jitterbug 1869 - this is an ambiguous era. (Showa 64 = Jan 6 1989, but Showa could be 2 other eras) )
|
||||
UnicodeString expect = CharsToUnicodeString("\\u662d\\u548c64\\u5e741\\u67086\\u65e5\\u91d1\\u66dc\\u65e5");
|
||||
UDate expectDate = 600076800000.0;
|
||||
Locale loc("ja_JP_TRADITIONAL");
|
||||
Locale loc("ja_JP@calendar=japanese");
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
simpleTest(loc, expect, expectDate, status);
|
||||
@ -483,7 +521,7 @@ void IntlCalendarTest::TestJapaneseFormat() {
|
||||
UnicodeString expect = CharsToUnicodeString("\\u5EB7\\u6B632\\u5e742\\u670829\\u65e5\\u65e5\\u66dc\\u65e5");
|
||||
// Add -1:00 to the following for historical TZ - aliu
|
||||
UDate expectDate = -16214403600000.0; // courtesy of date format round trip test
|
||||
Locale loc("ja_JP_TRADITIONAL");
|
||||
Locale loc("ja_JP@calendar=japanese");
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
simpleTest(loc, expect, expectDate, status);
|
||||
|
Loading…
Reference in New Issue
Block a user