Home | History | Annotate | Download | only in calendar
      1 //  2016 and later: Unicode, Inc. and others.
      2 // License & terms of use: http://www.unicode.org/copyright.html#License
      3 /*
      4  *******************************************************************************
      5  * Copyright (C) 2005-2010, International Business Machines Corporation and    *
      6  * others. All Rights Reserved.                                                *
      7  *******************************************************************************
      8  */
      9 package com.ibm.icu.dev.test.calendar;
     10 
     11 import java.util.Date;
     12 import java.util.Locale;
     13 
     14 import org.junit.Test;
     15 import org.junit.runner.RunWith;
     16 import org.junit.runners.JUnit4;
     17 
     18 import com.ibm.icu.impl.LocaleUtility;
     19 import com.ibm.icu.text.DateFormat;
     20 import com.ibm.icu.text.SimpleDateFormat;
     21 import com.ibm.icu.util.Calendar;
     22 import com.ibm.icu.util.EthiopicCalendar;
     23 import com.ibm.icu.util.GregorianCalendar;
     24 import com.ibm.icu.util.TimeZone;
     25 import com.ibm.icu.util.ULocale;
     26 
     27 /**
     28  * Tests for the <code>EthiopicCalendar</code> class.
     29  */
     30 @RunWith(JUnit4.class)
     31 public class EthiopicTest extends CalendarTestFmwk
     32 {
     33     /** Constants to save typing. */
     34     public static final int MESKEREM = EthiopicCalendar.MESKEREM;
     35     public static final int TEKEMT   = EthiopicCalendar.TEKEMT;
     36     public static final int HEDAR    = EthiopicCalendar.HEDAR;
     37     public static final int TAHSAS   = EthiopicCalendar.TAHSAS;
     38     public static final int TER      = EthiopicCalendar.TER;
     39     public static final int YEKATIT  = EthiopicCalendar.YEKATIT;
     40     public static final int MEGABIT  = EthiopicCalendar.MEGABIT;
     41     public static final int MIAZIA   = EthiopicCalendar.MIAZIA;
     42     public static final int GENBOT   = EthiopicCalendar.GENBOT;
     43     public static final int SENE     = EthiopicCalendar.SENE;
     44     public static final int HAMLE    = EthiopicCalendar.HAMLE;
     45     public static final int NEHASSE  = EthiopicCalendar.NEHASSE;
     46     public static final int PAGUMEN  = EthiopicCalendar.PAGUMEN;
     47 
     48     /* DY[20050507]  I don't know what this is for yet:
     49     @Test
     50     public void TestRoll() {
     51        int[][] tests = new int[][] {
     52        //       input                roll by          output
     53        //  year  month     day     field amount    year  month     day
     54 
     55        {   0001, QIDAH,     2,     MONTH,   1,     0001, HIJJAH,    2 },   // non-leap years
     56        {   0001, QIDAH,     2,     MONTH,   2,     0001, MUHARRAM,  2 },
     57        {   0001, QIDAH,     2,     MONTH,  -1,     0001, SHAWWAL,   2 },
     58        {   0001, MUHARRAM,  2,     MONTH,  12,     0001, MUHARRAM,  2 },
     59        {   0001, MUHARRAM,  2,     MONTH,  13,     0001, SAFAR,     2 },
     60 
     61        {   0001, HIJJAH,    1,     DATE,   30,     0001, HIJJAH,    2 },   // 29-day month
     62        {   0002, HIJJAH,    1,     DATE,   31,     0002, HIJJAH,    2 },   // 30-day month
     63 
     64        // Try some rolls that require other fields to be adjusted
     65        {   0001, MUHARRAM, 30,     MONTH,   1,     0001, SAFAR,    29 },
     66        {   0002, HIJJAH,   30,     YEAR,   -1,     0001, HIJJAH,   29 },
     67        };
     68 
     69        EthiopicCalendar cal = newCivil();
     70 
     71        doRollAdd(ROLL, cal, tests);
     72        }
     73     */
     74 
     75     /* Test dates from:
     76      * "The Amharic Letters of Emperor Theodore of Ethiopia to Queen Victoria and
     77      * Her Special Envoy", David Appleyard, Girma Selasse Asfaw, Oxford University Press,
     78      * June 1 1979, ISBN: 0856726605, Longwood Pr Ltd
     79      *
     80      * Ethiopic       Gregorian    JD
     81      * 20/02/1855     29/10/1862  2401443
     82      * 29/10/1857     05/07/1865  2402423
     83      * 22/05/1858     29/01/1866  2402631
     84      * 10/08/1858     17/04/1866  2402709
     85      * 28/04/1859     05/01/1867  2402972
     86      * 05/05/1860     13/01/1868  2403345
     87      *
     88      * --------------------------------------------------
     89      *
     90      * From the Calendrica applet:  http://emr.cs.iit.edu/home/reingold/calendar-book/Calendrica.html
     91      *
     92      * Ethiopic       Gregorian    JD
     93      * 07/05/-8       01/01/0000  1721060
     94      * 08/05/-7       01/01/0001  1721426
     95      * 06/13/-1       27/08/0007  1723855
     96      *
     97      * 01/01/0000     28/08/0007  1723856
     98      * 01/01/0001     27/08/0008  1724221
     99      * 01/01/0002     27/08/0009  1724586
    100      * 01/01/0003     27/08/0010  1724951
    101      * 01/01/0004     28/08/0011  1724537
    102      * 05/13/0000     26/08/0008  1724220
    103      * 05/13/0001     26/08/0009  1724585
    104      * 05/13/0002     26/08/0010  1724950
    105      * 05/13/0003     26/08/0011  1725315
    106      * 06/13/0003     27/08/0011  1725316  first ethiopian leap year
    107      * 05/13/0004     26/08/0012  1725561
    108      *
    109      * 06/02/1575     13/10/1582  2299159
    110      * 07/02/1575     14/10/1582  2299160  Julian 04/10/1582
    111      * 08/02/1575     15/10/1582  2299161
    112      * 09/02/1575     16/10/1582  2299162
    113      *
    114      * 23/04/1892     01/01/1900  2415021
    115      * 23/04/1997     01/01/2005  2453372
    116      * 05/13/2000     10/09/2008  2454720
    117      */
    118 
    119     /** A huge list of test cases to make sure that computeTime and computeFields
    120      * work properly for a wide range of data in the civil calendar.
    121      */
    122     @Test
    123     public void TestCases()
    124     {
    125         final TestCase[] tests = {
    126             //
    127             // The months in this table are 1-based rather than 0-based,
    128             // because it's easier to edit that way.
    129             //                      Ethiopic
    130             //          Julian Day  Era  Year  Month Day  WkDay Hour Min Sec
    131             //
    132             // Dates from "Emporer Theodore..."
    133 
    134             new TestCase(2401442.5,  1,  1855,    2,  20,  WED,   0,  0,  0), // Gregorian: 29/10/1862
    135             new TestCase(2402422.5,  1,  1857,   10,  29,  WED,   0,  0,  0), // Gregorian: 05/07/1865
    136             new TestCase(2402630.5,  1,  1858,    5,  22,  MON,   0,  0,  0), // Gregorian: 29/01/1866
    137             new TestCase(2402708.5,  1,  1858,    8,  10,  TUE,   0,  0,  0), // Gregorian: 17/04/1866
    138             new TestCase(2402971.5,  1,  1859,    4,  28,  SAT,   0,  0,  0), // Gregorian: 05/01/1867
    139             new TestCase(2403344.5,  1,  1860,    5,   5,  MON,   0,  0,  0), // Gregorian: 13/01/1868
    140 
    141             // Miscellaneous:
    142             /* Skip these tests until JD bug fixed in the Gregorian calendar:
    143              * http://www.jtcsv.com/cgibin/icu-bugs/incoming?id=4406;page=2;user=guest
    144              */
    145             new TestCase(1721059.5,  0,  5492,    5,   7,  SAT,   0,  0,  0), // Gregorian: 01/01/0000
    146             new TestCase(1721425.5,  0,  5493,    5,   8,  MON,   0,  0,  0), // Gregorian: 01/01/0001
    147             new TestCase(1723854.5,  0,  5499,   13,   6,  MON,   0,  0,  0), // Gregorian: 27/08/0007
    148 
    149             new TestCase(1723855.5,  0,  5500,    1,   1,  TUE,   0,  0,  0), // Gregorian: 28/08/0007
    150             new TestCase(1724220.5,  1,     1,    1,   1,  WED,   0,  0,  0), // Gregorian: 27/08/0008
    151             new TestCase(1724585.5,  1,     2,    1,   1,  THU,   0,  0,  0), // Gregorian: 27/08/0009
    152             new TestCase(1724950.5,  1,     3,    1,   1,  FRI,   0,  0,  0), // Gregorian: 27/08/0010
    153 
    154             // new TestCase(1724536.5,  1,     4,    1,   1,  SUN,   0,  0,  0), // Gregorian: 28/08/0011
    155             new TestCase(1725316.5,  1,     4,    1,   1,  SUN,   0,  0,  0), // Gregorian: 28/08/0011 - dlf
    156             new TestCase(1724219.5,  0,  5500,   13,   5,  TUE,   0,  0,  0), // Gregorian: 26/08/0008
    157             new TestCase(1724584.5,  1,     1,   13,   5,  WED,   0,  0,  0), // Gregorian: 26/08/0009
    158             new TestCase(1724949.5,  1,     2,   13,   5,  THU,   0,  0,  0), // Gregorian: 26/08/0010
    159             new TestCase(1725314.5,  1,     3,   13,   5,  FRI,   0,  0,  0), // Gregorian: 26/08/0011
    160             new TestCase(1725315.5,  1,     3,   13,   6,  SAT,   0,  0,  0), // Gregorian: 27/08/0011 - first ethiopic leap year
    161             // new TestCase(1725560.5,  1,     4,   13,   5,  SUN,   0,  0,  0), // Gregorian: 26/08/0012 - dlf
    162             new TestCase(1725680.5,  1,     4,   13,   5,  SUN,   0,  0,  0), // Gregorian: 26/08/0012
    163             new TestCase(2299158.5,  1,  1575,    2,   6,  WED,   0,  0,  0), // Gregorian: 13/10/1582
    164             new TestCase(2299159.5,  1,  1575,    2,   7,  THU,   0,  0,  0), // Gregorian: 14/10/1582  Julian 04/10/1582
    165 
    166             new TestCase(2299160.5,  1,  1575,    2,   8,  FRI,   0,  0,  0), // Gregorian: 15/10/1582
    167             new TestCase(2299161.5,  1,  1575,    2,   9,  SAT,   0,  0,  0), // Gregorian: 16/10/1582
    168 
    169             new TestCase(2415020.5,  1,  1892,    4,  23,  MON,   0,  0,  0), // Gregorian: 01/01/1900
    170             new TestCase(2453371.5,  1,  1997,    4,  23,  SAT,   0,  0,  0), // Gregorian: 01/01/2005
    171             new TestCase(2454719.5,  1,  2000,   13,   5,  WED,   0,  0,  0), // Gregorian: 10/09/2008
    172         };
    173 
    174         final TestCase[] testsAmeteAlem = {
    175                 //
    176                 // The months in this table are 1-based rather than 0-based,
    177                 // because it's easier to edit that way.
    178                 //                      Ethiopic
    179                 //          Julian Day  Era  Year  Month Day  WkDay Hour Min Sec
    180                 //
    181                 // Dates from "Emporer Theodore..."
    182 
    183                 new TestCase(2401442.5,  0,  7355,    2,  20,  WED,   0,  0,  0), // Gregorian: 29/10/1862
    184                 new TestCase(2402422.5,  0,  7357,   10,  29,  WED,   0,  0,  0), // Gregorian: 05/07/1865
    185                 new TestCase(2402630.5,  0,  7358,    5,  22,  MON,   0,  0,  0), // Gregorian: 29/01/1866
    186                 new TestCase(2402708.5,  0,  7358,    8,  10,  TUE,   0,  0,  0), // Gregorian: 17/04/1866
    187                 new TestCase(2402971.5,  0,  7359,    4,  28,  SAT,   0,  0,  0), // Gregorian: 05/01/1867
    188                 new TestCase(2403344.5,  0,  7360,    5,   5,  MON,   0,  0,  0), // Gregorian: 13/01/1868
    189 
    190                 // Miscellaneous:
    191                 /* Skip these tests until JD bug fixed in the Gregorian calendar:
    192                  * http://www.jtcsv.com/cgibin/icu-bugs/incoming?id=4406;page=2;user=guest
    193                  */
    194                 new TestCase(1721059.5,  0,  5492,    5,   7,  SAT,   0,  0,  0), // Gregorian: 01/01/0000
    195                 new TestCase(1721425.5,  0,  5493,    5,   8,  MON,   0,  0,  0), // Gregorian: 01/01/0001
    196                 new TestCase(1723854.5,  0,  5499,   13,   6,  MON,   0,  0,  0), // Gregorian: 27/08/0007
    197 
    198                 new TestCase(1723855.5,  0,  5500,    1,   1,  TUE,   0,  0,  0), // Gregorian: 28/08/0007
    199                 new TestCase(1724220.5,  0,  5501,    1,   1,  WED,   0,  0,  0), // Gregorian: 27/08/0008
    200                 new TestCase(1724585.5,  0,  5502,    1,   1,  THU,   0,  0,  0), // Gregorian: 27/08/0009
    201                 new TestCase(1724950.5,  0,  5503,    1,   1,  FRI,   0,  0,  0), // Gregorian: 27/08/0010
    202 
    203                 // new TestCase(1724536.5,  0,  5504,    1,   1,  SUN,   0,  0,  0), // Gregorian: 28/08/0011
    204                 new TestCase(1725316.5,  0,  5504,    1,   1,  SUN,   0,  0,  0), // Gregorian: 28/08/0011 - dlf
    205                 new TestCase(1724219.5,  0,  5500,   13,   5,  TUE,   0,  0,  0), // Gregorian: 26/08/0008
    206                 new TestCase(1724584.5,  0,  5501,   13,   5,  WED,   0,  0,  0), // Gregorian: 26/08/0009
    207                 new TestCase(1724949.5,  0,  5502,   13,   5,  THU,   0,  0,  0), // Gregorian: 26/08/0010
    208                 new TestCase(1725314.5,  0,  5503,   13,   5,  FRI,   0,  0,  0), // Gregorian: 26/08/0011
    209                 new TestCase(1725315.5,  0,  5503,   13,   6,  SAT,   0,  0,  0), // Gregorian: 27/08/0011 - first ethiopic leap year
    210                 // new TestCase(1725560.5,  0,  5504,   13,   5,  SUN,   0,  0,  0), // Gregorian: 26/08/0012 - dlf
    211                 new TestCase(1725680.5,  0,  5504,   13,   5,  SUN,   0,  0,  0), // Gregorian: 26/08/0012
    212                 new TestCase(2299158.5,  0,  7075,    2,   6,  WED,   0,  0,  0), // Gregorian: 13/10/1582
    213                 new TestCase(2299159.5,  0,  7075,    2,   7,  THU,   0,  0,  0), // Gregorian: 14/10/1582  Julian 04/10/1582
    214 
    215                 new TestCase(2299160.5,  0,  7075,    2,   8,  FRI,   0,  0,  0), // Gregorian: 15/10/1582
    216                 new TestCase(2299161.5,  0,  7075,    2,   9,  SAT,   0,  0,  0), // Gregorian: 16/10/1582
    217 
    218                 new TestCase(2415020.5,  0,  7392,    4,  23,  MON,   0,  0,  0), // Gregorian: 01/01/1900
    219                 new TestCase(2453371.5,  0,  7497,    4,  23,  SAT,   0,  0,  0), // Gregorian: 01/01/2005
    220                 new TestCase(2454719.5,  0,  7500,   13,   5,  WED,   0,  0,  0), // Gregorian: 10/09/2008
    221             };
    222 
    223         EthiopicCalendar testCalendar = new EthiopicCalendar();
    224         testCalendar.setLenient(true);
    225         doTestCases(tests, testCalendar);
    226 
    227         // Testing Amete Alem mode
    228 
    229         EthiopicCalendar testCalendarAmeteAlem = new EthiopicCalendar();
    230         testCalendarAmeteAlem.setAmeteAlemEra(true);
    231         testCalendarAmeteAlem.setLenient(true);
    232         doTestCases(testsAmeteAlem, testCalendarAmeteAlem);
    233     }
    234 
    235     // basic check to see that we print out eras ok
    236     // eventually should modify to use locale strings and formatter appropriate to coptic calendar
    237     @Test
    238     public void TestEraStart() {
    239         SimpleDateFormat fmt = new SimpleDateFormat("EEE MMM dd, yyyy GG");
    240         fmt.setCalendar(new EthiopicCalendar());
    241 
    242         EthiopicCalendar cal = new EthiopicCalendar(1, 0, 1);
    243         assertEquals("Ethiopic Date", "Wed Jan 01, 0001 AD", fmt.format(cal));
    244 
    245         cal.set(Calendar.ERA, 0);
    246         cal.set(Calendar.YEAR, 5500);
    247         assertEquals("Ethiopic Date", "Tue Jan 01, 5500 BC", fmt.format(cal));
    248 
    249         // The gregorian calendar gets off by two days when
    250         // the date gets low, unless the gregorian changeover is set to
    251         // very early.  The funny thing is, it's ok for dates in the year
    252         // 283, but not in the year 7, and it claims to be ok until the year 4.
    253         // should track down when the dates start to differ...
    254 
    255         GregorianCalendar gc = new GregorianCalendar();
    256         gc.setGregorianChange(new Date(Long.MIN_VALUE)); // act like proleptic Gregorian
    257         gc.setTime(cal.getTime());
    258         fmt.setCalendar(new GregorianCalendar());
    259         assertEquals("Gregorian Date", "Tue Aug 28, 0007 AD", fmt.format(gc));
    260     }
    261 
    262     @Test
    263     public void TestBasic() {
    264         EthiopicCalendar cal = new EthiopicCalendar();
    265         cal.clear();
    266         cal.set(1000, 0, 30);
    267         logln("1000/0/30-> " +
    268               cal.get(YEAR) + "/" +
    269               cal.get(MONTH) + "/" +
    270               cal.get(DATE));
    271         cal.clear();
    272         cal.set(1, 0, 30);
    273         logln("1/0/30 -> " +
    274               cal.get(YEAR) + "/" +
    275               cal.get(MONTH) + "/" +
    276               cal.get(DATE));
    277     }
    278 
    279     @Test
    280     public void TestJD(){
    281         int jd = EthiopicCalendar.EthiopicToJD(1567,8,9);
    282         EthiopicCalendar cal = new EthiopicCalendar();
    283         cal.clear();
    284         cal.set(Calendar.JULIAN_DAY, jd);
    285         if (cal.get(Calendar.EXTENDED_YEAR) == 1567 &&
    286             cal.get(Calendar.MONTH) == 8 &&
    287             cal.get(Calendar.DAY_OF_MONTH) == 9){
    288             logln("EthiopicCalendar.getDateFromJD tested");
    289         } else {
    290             errln("EthiopicCalendar.getDateFromJD failed");
    291         }
    292     }
    293 
    294     /**
    295      * Test limits of the Coptic calendar
    296      */
    297     @Test
    298     public void TestLimits() {
    299         Calendar cal = Calendar.getInstance();
    300         cal.set(2007, Calendar.JANUARY, 1);
    301         EthiopicCalendar ethiopic = new EthiopicCalendar();
    302         doLimitsTest(ethiopic, null, cal.getTime());
    303         doTheoreticalLimitsTest(ethiopic, true);
    304     }
    305 
    306 
    307     @Test
    308     public void TestCoverage() {
    309 
    310         {
    311             // new EthiopicCalendar(TimeZone)
    312             EthiopicCalendar cal = new EthiopicCalendar(TimeZone.getDefault());
    313             if(cal == null){
    314                 errln("could not create EthiopicCalendar with TimeZone");
    315             }
    316         }
    317 
    318         {
    319             // new EthiopicCalendar(ULocale)
    320             EthiopicCalendar cal = new EthiopicCalendar(ULocale.getDefault());
    321             if(cal == null){
    322                 errln("could not create EthiopicCalendar with ULocale");
    323             }
    324         }
    325 
    326         {
    327             // new EthiopicCalendar(Locale)
    328             EthiopicCalendar cal = new EthiopicCalendar(Locale.getDefault());
    329             if(cal == null){
    330                 errln("could not create EthiopicCalendar with Locale");
    331             }
    332         }
    333 
    334         {
    335             // new EthiopicCalendar(TimeZone, Locale)
    336             EthiopicCalendar cal = new EthiopicCalendar(TimeZone.getDefault(), Locale.getDefault());
    337             if(cal == null){
    338                 errln("could not create EthiopicCalendar with TimeZone,Locale");
    339             }
    340         }
    341 
    342         {
    343             // new EthiopicCalendar(TimeZone, ULocale)
    344             EthiopicCalendar cal = new EthiopicCalendar(TimeZone.getDefault(), ULocale.getDefault());
    345             if(cal == null){
    346                 errln("could not create EthiopicCalendar with TimeZone,ULocale");
    347             }
    348         }
    349 
    350         {
    351             // new EthiopicCalendar(Date)
    352             EthiopicCalendar cal = new EthiopicCalendar(new Date());
    353             if(cal == null){
    354                 errln("could not create EthiopicCalendar with Date");
    355             }
    356         }
    357 
    358         {
    359             // new EthiopicCalendar(int year, int month, int date)
    360             EthiopicCalendar cal = new EthiopicCalendar(1997, EthiopicCalendar.MESKEREM, 1);
    361             if(cal == null){
    362                 errln("could not create EthiopicCalendar with year,month,date");
    363             }
    364         }
    365 
    366         {
    367             // new EthiopicCalendar(int year, int month, int date, int hour, int minute, int second)
    368             EthiopicCalendar cal = new EthiopicCalendar(1997, EthiopicCalendar.MESKEREM, 1, 1, 1, 1);
    369             if(cal == null){
    370                 errln("could not create EthiopicCalendar with year,month,date,hour,minute,second");
    371             }
    372         }
    373 
    374         {
    375             // setCivil/isCivil
    376             // operations on non-civil calendar
    377             EthiopicCalendar cal = newAmeteAlemEraCalendar();
    378             cal.setAmeteAlemEra(false);
    379             if (cal.isAmeteAlemEra()) {
    380                 errln("EthiopicCalendar calendar is old system");
    381             }
    382 
    383             Date now = new Date();
    384             cal.setTime(now);
    385 
    386             Date then = cal.getTime();
    387             if (!now.equals(then)) {
    388                 errln("get/set time failed with non-civil EthiopicCalendar calendar");
    389             }
    390 
    391             logln(then.toString());
    392 
    393             cal.add(Calendar.MONTH, 1);
    394             cal.add(Calendar.DAY_OF_MONTH, 1);
    395             cal.add(Calendar.YEAR, 1);
    396 
    397             logln(cal.getTime().toString());
    398         }
    399 
    400         {
    401             // data
    402             EthiopicCalendar cal = new EthiopicCalendar(1997, EthiopicCalendar.MESKEREM, 1);
    403             Date time = cal.getTime();
    404 
    405             String[] calendarLocales = {
    406                 "am_ET", "gez_ET", "ti_ET"
    407             };
    408 
    409             String[] formatLocales = {
    410                 "en", "am", "gez", "ti"
    411             };
    412             for (int i = 0; i < calendarLocales.length; ++i) {
    413                 String calLocName = calendarLocales[i];
    414                 Locale calLocale = LocaleUtility.getLocaleFromName(calLocName);
    415                 cal = new EthiopicCalendar(calLocale);
    416 
    417                 for (int j = 0; j < formatLocales.length; ++j) {
    418                     String locName = formatLocales[j];
    419                     Locale formatLocale = LocaleUtility.getLocaleFromName(locName);
    420                     DateFormat format = DateFormat.getDateTimeInstance(cal, DateFormat.FULL, DateFormat.FULL, formatLocale);
    421                     logln(calLocName + "/" + locName + " --> " + format.format(time));
    422                 }
    423             }
    424         }
    425     }
    426 
    427     private static EthiopicCalendar newAmeteAlemEraCalendar() {
    428         EthiopicCalendar alemawiCalendar = new EthiopicCalendar();
    429         alemawiCalendar.setAmeteAlemEra(true);
    430         return alemawiCalendar;
    431     }
    432 
    433     @Test
    434     public void TestAddSet() {
    435         class TestAddSetItem {
    436             private int startYear;
    437             private int startMonth; // 0-based
    438             private int startDay; // 1-based
    439             private int fieldToChange;
    440             private int fieldDelta;
    441             private int endYear;
    442             private int endMonth;
    443             private int endDay;
    444             TestAddSetItem(int sYr, int sMo, int sDa, int field, int delta, int eYr, int eMo, int eDa) {
    445                 startYear = sYr;
    446                 startMonth = sMo;
    447                 startDay = sDa;
    448                 fieldToChange = field;
    449                 fieldDelta = delta;
    450                 endYear = eYr;
    451                 endMonth = eMo;
    452                 endDay = eDa;
    453             }
    454             public int getStartYear()  { return startYear; }
    455             public int getStartMonth() { return startMonth; }
    456             public int getStartDay()   { return startDay; }
    457             public int getField()      { return fieldToChange; }
    458             public int getDelta()      { return fieldDelta; }
    459             public int getEndYear()    { return endYear; }
    460             public int getEndMonth()   { return endMonth; }
    461             public int getEndDay()     { return endDay; }
    462         }
    463         final TestAddSetItem[] tests = {
    464             new TestAddSetItem( 2000, 12, 1, Calendar.MONTH, +1, 2001,  0, 1 ),
    465             new TestAddSetItem( 2000, 12, 1, Calendar.MONTH, +9, 2001,  8, 1 ),
    466             new TestAddSetItem( 1999, 12, 2, Calendar.MONTH, +1, 2000,  0, 2 ), // 1999 is a leap year
    467             new TestAddSetItem( 1999, 12, 2, Calendar.MONTH, +9, 2000,  8, 2 ),
    468             new TestAddSetItem( 2001,  0, 1, Calendar.MONTH, -1, 2000, 12, 1 ),
    469             new TestAddSetItem( 2001,  0, 1, Calendar.MONTH, -6, 2000,  7, 1 ),
    470             new TestAddSetItem( 2000, 12, 1, Calendar.DATE,  +8, 2001,  0, 4 ),
    471             new TestAddSetItem( 1999, 12, 1, Calendar.DATE,  +8, 2000,  0, 3 ), // 1999 is a leap year
    472             new TestAddSetItem( 2000,  0, 1, Calendar.DATE,  -1, 1999, 12, 6 ),
    473         };
    474         EthiopicCalendar testCalendar = new EthiopicCalendar();
    475         for ( int i = 0; i < tests.length; i++ ) {
    476             TestAddSetItem item = tests[i];
    477             testCalendar.set( item.getStartYear(), item.getStartMonth(), item.getStartDay(), 9, 0 );
    478             testCalendar.add( item.getField(), item.getDelta() );
    479             int endYear = testCalendar.get(Calendar.YEAR);
    480             int endMonth = testCalendar.get(Calendar.MONTH);
    481             int endDay = testCalendar.get(Calendar.DATE);
    482             if ( endYear != item.getEndYear() || endMonth != item.getEndMonth() || endDay != item.getEndDay() ) {
    483                 errln("EToJD FAILS: field " + item.getField() + " delta " + item.getDelta() +
    484                             " expected yr " + item.getEndYear() + " mo " + item.getEndMonth() +  " da " + item.getEndDay() +
    485                             " got yr " + endYear + " mo " + endMonth +  " da " + endDay);
    486             }
    487         }
    488     }
    489 }
    490