ICU-1624 Add additional tests for Hebrew Calendar

X-SVN-Rev: 26844
This commit is contained in:
John Emmons 2009-11-03 05:21:20 +00:00
parent 82dde07d7d
commit 20b3037ed2

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 1996-2007, International Business Machines Corporation and *
* Copyright (C) 1996-2009, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -459,4 +459,41 @@ public class HebrewTest extends CalendarTest {
warnln("Could not load the locale data. "+ ex.getMessage());
}
}
public void Test1624() {
HebrewCalendar hc = new HebrewCalendar (5742, HebrewCalendar.AV, 22);
DateFormat df = hc.getDateTimeFormat(DateFormat.FULL, DateFormat.FULL, Locale.getDefault());
String dateString = df.format(hc.getTime());
for (int year = 5600; year < 5800; year ++) {
boolean leapYear = HebrewCalendar.isLeapYear (year);
for (int month = HebrewCalendar.TISHRI; month <= HebrewCalendar.ELUL;month++) {
// skip the adar 1 month if year is not a leap year
if (leapYear == false && month == HebrewCalendar.ADAR_1) {
continue;
}
int day = 15;
hc = new HebrewCalendar (year, month, day);
dateString = df.format(hc.getTime());
int dayHC = hc.get (HebrewCalendar.DATE);
int monthHC = hc.get (HebrewCalendar.MONTH);
int yearHC = hc.get (HebrewCalendar.YEAR);
String header = "year:" + year + " isleap:" + leapYear + " " + dateString;
if (dayHC != day) {
errln (header + " ==> day:" + dayHC + " incorrect, should be:" + day);
break;
}
if (monthHC != month) {
errln (header + " ==> month:" + monthHC + " incorrect, should be:" + month);
break;
}
if (yearHC != year) {
errln (header + " ==> year:" + yearHC + " incorrecte, should be:" + year);
break;
}
}
}
}
}