From 20b3037ed2aa3aa541af2f8b6413a4a07befb1c2 Mon Sep 17 00:00:00 2001 From: John Emmons Date: Tue, 3 Nov 2009 05:21:20 +0000 Subject: [PATCH] ICU-1624 Add additional tests for Hebrew Calendar X-SVN-Rev: 26844 --- .../ibm/icu/dev/test/calendar/HebrewTest.java | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/HebrewTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/HebrewTest.java index e3a39146fb..8f76fb3939 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/HebrewTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/HebrewTest.java @@ -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; + } + } + } + } }