Home | History | Annotate | Download | only in format
      1 /* GENERATED SOURCE. DO NOT MODIFY. */
      2 //  2016 and later: Unicode, Inc. and others.
      3 // License & terms of use: http://www.unicode.org/copyright.html#License
      4 /*****************************************************************************************
      5  *
      6  *   Copyright (C) 1996-2014, International Business Machines
      7  *   Corporation and others.  All Rights Reserved.
      8  **/
      9 
     10 /**
     11  * Port From:   JDK 1.4b1 : java.text.Format.IntlTestDateFormatSymbols
     12  * Source File: java/text/format/IntlTestDateFormatSymbols.java
     13  **/
     14 
     15 /*
     16     @test 1.4 98/03/06
     17     @summary test International Date Format Symbols
     18 */
     19 
     20 package android.icu.dev.test.format;
     21 
     22 import java.util.Locale;
     23 
     24 import org.junit.Test;
     25 import org.junit.runner.RunWith;
     26 import org.junit.runners.JUnit4;
     27 
     28 import android.icu.dev.test.TestFmwk;
     29 import android.icu.text.DateFormatSymbols;
     30 import android.icu.util.Calendar;
     31 import android.icu.util.ULocale;
     32 import android.icu.testsharding.MainTestShard;
     33 
     34 @MainTestShard
     35 @RunWith(JUnit4.class)
     36 public class IntlTestDateFormatSymbols extends TestFmwk
     37 {
     38     // Test getMonths
     39     @Test
     40     public void TestGetMonths()
     41     {
     42         final String[] month;
     43         DateFormatSymbols symbol;
     44 
     45         symbol=new DateFormatSymbols(Locale.getDefault());
     46 
     47         month=symbol.getMonths();
     48         int cnt = month.length;
     49 
     50         logln("size = " + cnt);
     51 
     52         for (int i=0; i<cnt; ++i)
     53         {
     54             logln(month[i]);
     55         }
     56     }
     57 
     58     @Test
     59     public void TestGetMonths2()
     60     {
     61         DateFormatSymbols symbol;
     62         symbol=new DateFormatSymbols(Locale.getDefault());
     63 
     64         int[] context = {DateFormatSymbols.STANDALONE, DateFormatSymbols.FORMAT};
     65         int[] width = {DateFormatSymbols.WIDE, DateFormatSymbols.ABBREVIATED, DateFormatSymbols.NARROW};
     66 
     67         for (int i = 0; i < context.length; i++) {
     68             for (int j = 0; j < width.length; j++) {
     69                 String[] month =symbol.getMonths(context[i],width[j]);
     70                 int cnt = month.length;
     71 
     72                 logln("size = " + cnt);
     73 
     74                 for (int k = 0; k < month.length; k++) {
     75                     logln(month[k]);
     76                 }
     77             }
     78         }
     79     }
     80 
     81     @Test
     82     public void TestGetWeekdays2(){
     83         DateFormatSymbols symbol;
     84         symbol=new DateFormatSymbols(Locale.getDefault());
     85 
     86         int[] context = {DateFormatSymbols.STANDALONE, DateFormatSymbols.FORMAT};
     87         int[] width = {DateFormatSymbols.WIDE, DateFormatSymbols.ABBREVIATED, DateFormatSymbols.NARROW};
     88 
     89         for (int i = 0; i < context.length; i++) {
     90             for (int j = 0; j < width.length; j++) {
     91                 String[] wd =symbol.getWeekdays(context[i],width[j]);
     92                 int cnt = wd.length;
     93 
     94                 logln("size = " + cnt);
     95 
     96                 for (int k = 0; k < wd.length; k++) {
     97                     logln(wd[k]);
     98                 }
     99             }
    100         }
    101 
    102     }
    103 
    104     @Test
    105     public void TestGetEraNames(){
    106         DateFormatSymbols symbol;
    107         symbol=new DateFormatSymbols(Locale.getDefault());
    108         String[] s = symbol.getEraNames();
    109         for (int i = 0; i < s.length; i++) {
    110             logln(s[i]);
    111         }
    112 
    113     }
    114 
    115     private boolean UnicodeStringsArePrefixes(String[] prefixArray, String[] baseArray){
    116         if (prefixArray.length != baseArray.length) {
    117             return false;
    118         }
    119         int i;
    120         for (i = 0; i < baseArray.length; i++) {
    121             if (!baseArray[i].startsWith(prefixArray[i])) {
    122                 errln("ERROR: Mismatch example, index " + i + ": expect prefix \"" + prefixArray[i] + "\" of base \"" + baseArray[i] + "\".");
    123             	return false;
    124             }
    125         }
    126         return true;
    127     }
    128 
    129 
    130     // Test the API of DateFormatSymbols; primarily a simple get/set set.
    131     @Test
    132     public void TestSymbols()
    133     {
    134         DateFormatSymbols fr = new DateFormatSymbols(Locale.FRENCH);
    135         DateFormatSymbols fr2 = new DateFormatSymbols(Locale.FRENCH);
    136 
    137         DateFormatSymbols en = new DateFormatSymbols(Locale.ENGLISH);
    138 
    139         DateFormatSymbols zhChiCal = new DateFormatSymbols(new ULocale("zh@calendar=chinese"));
    140 
    141         if(en.equals(fr)) {
    142             errln("ERROR: English DateFormatSymbols equal to French");
    143         }
    144 
    145         // just do some VERY basic tests to make sure that get/set work
    146 
    147         long count;
    148         final String[] eras = en.getEras();
    149         fr.setEras(eras);
    150         final String[] eras1 = fr.getEras();
    151         count = eras.length;
    152         if( count != eras1.length) {
    153             errln("ERROR: setEras() failed (different size array)");
    154         }
    155         else {
    156             for(int i = 0; i < count; i++) {
    157                 if(! eras[i].equals(eras1[i])) {
    158                     errln("ERROR: setEras() failed (different string values)");
    159                 }
    160             }
    161         }
    162 
    163 
    164         final String[] months = en.getMonths();
    165         fr.setMonths(months);
    166         final String[] months1 = fr.getMonths();
    167         count = months.length;
    168         if( count != months1.length) {
    169             errln("ERROR: setMonths() failed (different size array)");
    170         }
    171         else {
    172             for(int i = 0; i < count; i++) {
    173                 if(! months[i].equals(months1[i])) {
    174                     errln("ERROR: setMonths() failed (different string values)");
    175                 }
    176             }
    177         }
    178 
    179         final String[] shortMonths = en.getShortMonths();
    180         fr.setShortMonths(shortMonths);
    181         final String[] shortMonths1 = fr.getShortMonths();
    182         count = shortMonths.length;
    183         if( count != shortMonths1.length) {
    184             errln("ERROR: setShortMonths() failed (different size array)");
    185         }
    186         else {
    187             for(int i = 0; i < count; i++) {
    188                 if(! shortMonths[i].equals(shortMonths1[i])) {
    189                     errln("ERROR: setShortMonths() failed (different string values)");
    190                 }
    191             }
    192         }
    193 
    194         final String[] wideMonths = en.getMonths(DateFormatSymbols.FORMAT,DateFormatSymbols.WIDE);
    195         fr2.setMonths(wideMonths,DateFormatSymbols.FORMAT,DateFormatSymbols.WIDE);
    196         final String[] wideMonths1 = fr2.getMonths(DateFormatSymbols.FORMAT,DateFormatSymbols.WIDE);
    197         count = wideMonths.length;
    198         if( count != wideMonths1.length) {
    199             errln("ERROR: setMonths(FORMAT,WIDE) failed (different size array)");
    200         }
    201         else {
    202             for(int i = 0; i < count; i++) {
    203                 if(! wideMonths[i].equals(wideMonths1[i])) {
    204                     errln("ERROR: setMonths(FORMAT,WIDE) failed (different string values)");
    205                 }
    206             }
    207         }
    208 
    209         final String[] abbrMonths = en.getMonths(DateFormatSymbols.FORMAT,DateFormatSymbols.ABBREVIATED);
    210         fr2.setMonths(abbrMonths,DateFormatSymbols.FORMAT,DateFormatSymbols.ABBREVIATED);
    211         final String[] abbrMonths1 = fr2.getMonths(DateFormatSymbols.FORMAT,DateFormatSymbols.ABBREVIATED);
    212         count = abbrMonths.length;
    213         if( count != abbrMonths1.length) {
    214             errln("ERROR: setMonths(FORMAT,ABBREVIATED) failed (different size array)");
    215         }
    216         else {
    217             for(int i = 0; i < count; i++) {
    218                 if(! abbrMonths[i].equals(abbrMonths1[i])) {
    219                     errln("ERROR: setMonths(FORMAT,ABBREVIATED) failed (different string values)");
    220                 }
    221             }
    222         }
    223 
    224         final String[] narrowMonths = en.getMonths(DateFormatSymbols.FORMAT,DateFormatSymbols.NARROW);
    225         fr.setMonths(narrowMonths,DateFormatSymbols.FORMAT,DateFormatSymbols.NARROW);
    226         final String[] narrowMonths1 = fr.getMonths(DateFormatSymbols.FORMAT,DateFormatSymbols.NARROW);
    227         count = narrowMonths.length;
    228         if( count != narrowMonths1.length) {
    229             errln("ERROR: setMonths(FORMAT,NARROW) failed (different size array)");
    230         }
    231         else {
    232             for(int i = 0; i < count; i++) {
    233                 if(! narrowMonths[i].equals(narrowMonths1[i])) {
    234                     errln("ERROR: setMonths(FORMAT,NARROW) failed (different string values)");
    235                 }
    236             }
    237         }
    238 
    239         final String[] standaloneMonths = en.getMonths(DateFormatSymbols.STANDALONE,DateFormatSymbols.WIDE);
    240         fr.setMonths(standaloneMonths,DateFormatSymbols.STANDALONE,DateFormatSymbols.WIDE);
    241         final String[] standaloneMonths1 = fr.getMonths(DateFormatSymbols.STANDALONE,DateFormatSymbols.WIDE);
    242         count = standaloneMonths.length;
    243         if( count != standaloneMonths1.length) {
    244             errln("ERROR: setMonths(STANDALONE,WIDE) failed (different size array)");
    245         }
    246         else {
    247             for(int i = 0; i < count; i++) {
    248                 if(! standaloneMonths[i].equals(standaloneMonths1[i])) {
    249                     errln("ERROR: setMonths(STANDALONE,WIDE) failed (different string values)");
    250                 }
    251             }
    252         }
    253 
    254         final String[] standaloneShortMonths = en.getMonths(DateFormatSymbols.STANDALONE,DateFormatSymbols.ABBREVIATED);
    255         fr.setMonths(standaloneShortMonths,DateFormatSymbols.STANDALONE,DateFormatSymbols.ABBREVIATED);
    256         final String[] standaloneShortMonths1 = fr.getMonths(DateFormatSymbols.STANDALONE,DateFormatSymbols.ABBREVIATED);
    257         count = standaloneShortMonths.length;
    258         if( count != standaloneShortMonths1.length) {
    259             errln("ERROR: setMonths(STANDALONE,ABBREVIATED) failed (different size array)");
    260         }
    261         else {
    262             for(int i = 0; i < count; i++) {
    263                 if(! standaloneShortMonths[i].equals(standaloneShortMonths1[i])) {
    264                     errln("ERROR: setMonths(STANDALONE,ABBREVIATED) failed (different string values)");
    265                 }
    266             }
    267         }
    268 
    269         final String[] standaloneNarrowMonths = en.getMonths(DateFormatSymbols.STANDALONE,DateFormatSymbols.NARROW);
    270         fr.setMonths(standaloneNarrowMonths,DateFormatSymbols.STANDALONE,DateFormatSymbols.NARROW);
    271         final String[] standaloneNarrowMonths1 = fr.getMonths(DateFormatSymbols.STANDALONE,DateFormatSymbols.NARROW);
    272         count = standaloneNarrowMonths.length;
    273         if( count != standaloneNarrowMonths1.length) {
    274             errln("ERROR: setMonths(STANDALONE,NARROW) failed (different size array)");
    275         }
    276         else {
    277             for(int i = 0; i < count; i++) {
    278                 if(! standaloneNarrowMonths[i].equals(standaloneNarrowMonths1[i])) {
    279                     errln("ERROR: setMonths(STANDALONE,NARROW) failed (different string values)");
    280                 }
    281             }
    282         }
    283 
    284         final String[] weekdays = en.getWeekdays();
    285         fr.setWeekdays(weekdays);
    286         final String[] weekdays1 = fr.getWeekdays();
    287         count = weekdays.length;
    288         if( count != weekdays1.length) {
    289             errln("ERROR: setWeekdays() failed (different size array)");
    290         }
    291         else {
    292             for(int i = 0; i < count; i++) {
    293                 if(! weekdays[i].equals(weekdays1[i])) {
    294                     errln("ERROR: setWeekdays() failed (different string values)");
    295                 }
    296             }
    297         }
    298 
    299         final String[] shortWeekdays = en.getShortWeekdays();
    300         fr.setShortWeekdays(shortWeekdays);
    301         final String[] shortWeekdays1 = fr.getShortWeekdays();
    302         count = shortWeekdays.length;
    303         if( count != shortWeekdays1.length) {
    304             errln("ERROR: setShortWeekdays() failed (different size array)");
    305         }
    306         else {
    307             for(int i = 0; i < count; i++) {
    308                 if(! shortWeekdays[i].equals(shortWeekdays1[i])) {
    309                     errln("ERROR: setShortWeekdays() failed (different string values)");
    310                 }
    311             }
    312         }
    313 
    314         final String[] wideWeekdays = en.getWeekdays(DateFormatSymbols.FORMAT,DateFormatSymbols.WIDE);
    315         fr2.setWeekdays(wideWeekdays,DateFormatSymbols.FORMAT,DateFormatSymbols.WIDE);
    316         final String[] wideWeekdays1 = fr2.getWeekdays(DateFormatSymbols.FORMAT,DateFormatSymbols.WIDE);
    317         count = wideWeekdays.length;
    318         if( count != wideWeekdays1.length) {
    319             errln("ERROR: setWeekdays(FORMAT,WIDE) failed (different size array)");
    320         }
    321         else {
    322             for(int i = 0; i < count; i++) {
    323                 if(! wideWeekdays[i].equals(wideWeekdays1[i])) {
    324                     errln("ERROR: setWeekdays(FORMAT,WIDE) failed (different string values)");
    325                 }
    326             }
    327         }
    328 
    329         final String[] abbrWeekdays = en.getWeekdays(DateFormatSymbols.FORMAT,DateFormatSymbols.ABBREVIATED);
    330         final String[] shorterWeekdays = en.getWeekdays(DateFormatSymbols.FORMAT,DateFormatSymbols.SHORT);
    331         if ( !UnicodeStringsArePrefixes(shorterWeekdays, abbrWeekdays) ) {
    332             errln("ERROR: English format short weekday names don't match prefixes of format abbreviated names");
    333         }
    334         fr2.setWeekdays(abbrWeekdays,DateFormatSymbols.FORMAT,DateFormatSymbols.ABBREVIATED);
    335         final String[] abbrWeekdays1 = fr2.getWeekdays(DateFormatSymbols.FORMAT,DateFormatSymbols.ABBREVIATED);
    336         count = abbrWeekdays.length;
    337         if( count != abbrWeekdays1.length) {
    338             errln("ERROR: setWeekdays(FORMAT,ABBREVIATED) failed (different size array)");
    339         }
    340         else {
    341             for(int i = 0; i < count; i++) {
    342                 if(! abbrWeekdays[i].equals(abbrWeekdays1[i])) {
    343                     errln("ERROR: setWeekdays(FORMAT,ABBREVIATED) failed (different string values)");
    344                 }
    345             }
    346         }
    347 
    348         final String[] narrowWeekdays = en.getWeekdays(DateFormatSymbols.FORMAT,DateFormatSymbols.NARROW);
    349         fr.setWeekdays(narrowWeekdays,DateFormatSymbols.FORMAT,DateFormatSymbols.NARROW);
    350         final String[] narrowWeekdays1 = fr.getWeekdays(DateFormatSymbols.FORMAT,DateFormatSymbols.NARROW);
    351         count = narrowWeekdays.length;
    352         if( count != narrowWeekdays1.length) {
    353             errln("ERROR: setWeekdays(FORMAT,NARROW) failed (different size array)");
    354         }
    355         else {
    356             for(int i = 0; i < count; i++) {
    357                 if(! narrowWeekdays[i].equals(narrowWeekdays1[i])) {
    358                     errln("ERROR: setWeekdays(FORMAT,NARROW) failed (different string values)");
    359                 }
    360             }
    361         }
    362 
    363         final String[] standaloneWeekdays = en.getWeekdays(DateFormatSymbols.STANDALONE,DateFormatSymbols.WIDE);
    364         fr.setWeekdays(standaloneWeekdays,DateFormatSymbols.STANDALONE,DateFormatSymbols.WIDE);
    365         final String[] standaloneWeekdays1 = fr.getWeekdays(DateFormatSymbols.STANDALONE,DateFormatSymbols.WIDE);
    366         count = standaloneWeekdays.length;
    367         if( count != standaloneWeekdays1.length) {
    368             errln("ERROR: setWeekdays(STANDALONE,WIDE) failed (different size array)");
    369         }
    370         else {
    371             for(int i = 0; i < count; i++) {
    372                 if(! standaloneWeekdays[i].equals(standaloneWeekdays1[i])) {
    373                     errln("ERROR: setWeekdays(STANDALONE,WIDE) failed (different string values)");
    374                 }
    375             }
    376         }
    377 
    378         final String[] standaloneShortWeekdays = en.getWeekdays(DateFormatSymbols.STANDALONE,DateFormatSymbols.ABBREVIATED);
    379         final String[] standaloneShorterWeekdays = en.getWeekdays(DateFormatSymbols.STANDALONE,DateFormatSymbols.SHORT);
    380         if ( !UnicodeStringsArePrefixes(standaloneShorterWeekdays, standaloneShortWeekdays) ) {
    381             errln("ERROR: English standalone short weekday names don't match prefixes of standalone abbreviated names");
    382         }
    383         fr.setWeekdays(standaloneShortWeekdays,DateFormatSymbols.STANDALONE,DateFormatSymbols.ABBREVIATED);
    384         final String[] standaloneShortWeekdays1 = fr.getWeekdays(DateFormatSymbols.STANDALONE,DateFormatSymbols.ABBREVIATED);
    385         count = standaloneShortWeekdays.length;
    386         if( count != standaloneShortWeekdays1.length) {
    387             errln("ERROR: setWeekdays(STANDALONE,ABBREVIATED) failed (different size array)");
    388         }
    389         else {
    390             for(int i = 0; i < count; i++) {
    391                 if(! standaloneShortWeekdays[i].equals(standaloneShortWeekdays1[i])) {
    392                     errln("ERROR: setWeekdays(STANDALONE,ABBREVIATED) failed (different string values)");
    393                 }
    394             }
    395         }
    396 
    397         final String[] standaloneNarrowWeekdays = en.getWeekdays(DateFormatSymbols.STANDALONE,DateFormatSymbols.NARROW);
    398         fr.setWeekdays(standaloneNarrowWeekdays,DateFormatSymbols.STANDALONE,DateFormatSymbols.NARROW);
    399         final String[] standaloneNarrowWeekdays1 = fr.getWeekdays(DateFormatSymbols.STANDALONE,DateFormatSymbols.NARROW);
    400         count = standaloneNarrowWeekdays.length;
    401         if( count != standaloneNarrowWeekdays1.length) {
    402             errln("ERROR: setWeekdays(STANDALONE,NARROW) failed (different size array)");
    403         }
    404         else {
    405             for(int i = 0; i < count; i++) {
    406                 if(! standaloneNarrowWeekdays[i].equals(standaloneNarrowWeekdays1[i])) {
    407                     errln("ERROR: setWeekdays(STANDALONE,NARROW) failed (different string values)");
    408                 }
    409             }
    410         }
    411 
    412         final String[] wideQuarters = en.getQuarters(DateFormatSymbols.FORMAT,DateFormatSymbols.WIDE);
    413         fr2.setQuarters(wideQuarters,DateFormatSymbols.FORMAT,DateFormatSymbols.WIDE);
    414         final String[] wideQuarters1 = fr2.getQuarters(DateFormatSymbols.FORMAT,DateFormatSymbols.WIDE);
    415         count = wideQuarters.length;
    416         if( count != wideQuarters1.length) {
    417             errln("ERROR: setQuarters(FORMAT, WIDE) failed (different size array)");
    418         }
    419         else {
    420             for(int i = 0; i < count; i++) {
    421                 if(! wideQuarters[i].equals(wideQuarters1[i])) {
    422                     errln("ERROR: setQuarters(FORMAT, WIDE) failed (different string values)");
    423                 }
    424             }
    425         }
    426 
    427         final String[] abbrQuarters = en.getQuarters(DateFormatSymbols.FORMAT,DateFormatSymbols.ABBREVIATED);
    428         fr2.setQuarters(abbrQuarters,DateFormatSymbols.FORMAT,DateFormatSymbols.ABBREVIATED);
    429         final String[] abbrQuarters1 = fr2.getQuarters(DateFormatSymbols.FORMAT,DateFormatSymbols.ABBREVIATED);
    430         count = abbrQuarters.length;
    431         if( count != abbrQuarters1.length) {
    432             errln("ERROR: setQuarters(FORMAT, ABBREVIATED) failed (different size array)");
    433         }
    434         else {
    435             for(int i = 0; i < count; i++) {
    436                 if(! abbrQuarters[i].equals(abbrQuarters1[i])) {
    437                     errln("ERROR: setQuarters(FORMAT, ABBREVIATED) failed (different string values)");
    438                 }
    439             }
    440         }
    441 
    442         final String[] standaloneQuarters = en.getQuarters(DateFormatSymbols.STANDALONE,DateFormatSymbols.WIDE);
    443         fr.setQuarters(standaloneQuarters,DateFormatSymbols.STANDALONE,DateFormatSymbols.WIDE);
    444         final String[] standaloneQuarters1 = fr.getQuarters(DateFormatSymbols.STANDALONE,DateFormatSymbols.WIDE);
    445         count = standaloneQuarters.length;
    446         if( count != standaloneQuarters1.length) {
    447             errln("ERROR: setQuarters(STANDALONE, WIDE) failed (different size array)");
    448         }
    449         else {
    450             for(int i = 0; i < count; i++) {
    451                 if(! standaloneQuarters[i].equals(standaloneQuarters1[i])) {
    452                     errln("ERROR: setQuarters(STANDALONE, WIDE) failed (different string values)");
    453                 }
    454             }
    455         }
    456 
    457         final String[] standaloneShortQuarters = en.getQuarters(DateFormatSymbols.STANDALONE,DateFormatSymbols.ABBREVIATED);
    458         fr.setQuarters(standaloneShortQuarters,DateFormatSymbols.STANDALONE,DateFormatSymbols.ABBREVIATED);
    459         final String[] standaloneShortQuarters1 = fr.getQuarters(DateFormatSymbols.STANDALONE,DateFormatSymbols.ABBREVIATED);
    460         count = standaloneShortQuarters.length;
    461         if( count != standaloneShortQuarters1.length) {
    462             errln("ERROR: setQuarters(STANDALONE, ABBREVIATED) failed (different size array)");
    463         }
    464         else {
    465             for(int i = 0; i < count; i++) {
    466                 if(! standaloneShortQuarters[i].equals(standaloneShortQuarters1[i])) {
    467                     errln("ERROR: setQuarters(STANDALONE, ABBREVIATED) failed (different string values)");
    468                 }
    469             }
    470         }
    471 
    472         final String[] ampms = en.getAmPmStrings();
    473         fr.setAmPmStrings(ampms);
    474         final String[] ampms1 = fr.getAmPmStrings();
    475         count = ampms.length;
    476         if( count != ampms1.length) {
    477             errln("ERROR: setAmPmStrings() failed (different size array)");
    478         }
    479         else {
    480             for(int i = 0; i < count; i++) {
    481                 if(! ampms[i].equals(ampms1[i])) {
    482                     errln("ERROR: setAmPmStrings() failed (different string values)");
    483                 }
    484             }
    485         }
    486 
    487         long rowCount = 0, columnCount = 0;
    488         final String[][] strings = en.getZoneStrings();
    489         fr.setZoneStrings(strings);
    490         final String[][] strings1 = fr.getZoneStrings();
    491         rowCount = strings.length;
    492         for(int i = 0; i < rowCount; i++) {
    493             columnCount = strings[i].length;
    494             for(int j = 0; j < columnCount; j++) {
    495                 if( strings[i][j] != strings1[i][j] ) {
    496                     errln("ERROR: setZoneStrings() failed");
    497                 }
    498             }
    499         }
    500 
    501 //        final String pattern = DateFormatSymbols.getPatternChars();
    502 
    503         String localPattern; // pat1, pat2; //The variable is never used
    504         localPattern = en.getLocalPatternChars();
    505         fr.setLocalPatternChars(localPattern);
    506         if(! en.getLocalPatternChars().equals(fr.getLocalPatternChars())) {
    507             errln("ERROR: setLocalPatternChars() failed");
    508         }
    509 
    510 
    511         //DateFormatSymbols foo = new DateFormatSymbols(); //The variable is never used
    512 
    513         en = (DateFormatSymbols) fr.clone();
    514 
    515         if(! en.equals(fr)) {
    516             errln("ERROR: Clone failed");
    517         }
    518 
    519         final String[] shortYearNames = zhChiCal.getYearNames(DateFormatSymbols.FORMAT, DateFormatSymbols.ABBREVIATED);
    520         final String[] narrowYearNames = zhChiCal.getYearNames(DateFormatSymbols.STANDALONE, DateFormatSymbols.NARROW);
    521         if (shortYearNames == null || shortYearNames.length != 60 ||
    522                 !shortYearNames[0].equals("\u7532\u5B50") || !shortYearNames[59].equals("\u7678\u4EA5")) {
    523             errln("ERROR: invalid FORMAT/ABBREVIATED year names from zh@calendar=chinese");
    524         }
    525         if (narrowYearNames == null || narrowYearNames.length != 60 ||
    526                 !narrowYearNames[0].equals("\u7532\u5B50") || !narrowYearNames[59].equals("\u7678\u4EA5")) {
    527             errln("ERROR: invalid STANDALONE/NARROW year names from zh@calendar=chinese");
    528         }
    529         final String[] enGregoYearNames = en.getYearNames(DateFormatSymbols.FORMAT, DateFormatSymbols.ABBREVIATED);
    530         if (enGregoYearNames != null) {
    531             errln("ERROR: yearNames not null for en");
    532         }
    533 
    534         final String[] shortZodiacNames = zhChiCal.getZodiacNames(DateFormatSymbols.FORMAT, DateFormatSymbols.ABBREVIATED);
    535         if (shortZodiacNames == null || shortZodiacNames.length != 12 ||
    536                 !shortZodiacNames[0].equals("\u9F20") || !shortZodiacNames[11].equals("\u732A")) {
    537             errln("ERROR: invalid FORMAT/ABBREVIATED zodiac names from zh@calendar=chinese");
    538         }
    539 
    540         final String[] newZodiacNames = {"Rat","Ox","Tiger","Rabbit","Dragon","Snake","Horse","Goat","Monkey","Rooster","Dog","Pig"};
    541         zhChiCal.setZodiacNames(newZodiacNames, DateFormatSymbols.FORMAT, DateFormatSymbols.ABBREVIATED);
    542         final String[] testZodiacNames = zhChiCal.getZodiacNames(DateFormatSymbols.FORMAT, DateFormatSymbols.ABBREVIATED);
    543         if (testZodiacNames == null || testZodiacNames.length != 12 ||
    544                 !testZodiacNames[0].equals("Rat") || !testZodiacNames[11].equals("Pig")) {
    545             errln("ERROR: setZodiacNames then getZodiacNames not working for zh@calendar=chinese");
    546         }
    547 
    548         String leapMonthPatternFmtAbbrev = zhChiCal.getLeapMonthPattern(DateFormatSymbols.FORMAT, DateFormatSymbols.ABBREVIATED);
    549         if (leapMonthPatternFmtAbbrev == null || !leapMonthPatternFmtAbbrev.equals("\u95F0{0}")) {
    550             errln("ERROR: invalid FORMAT/ABBREVIATED leapMonthPattern from zh@calendar=chinese");
    551         }
    552     }
    553 
    554     @Test
    555     public void TestConstructorWithCalendar() {
    556         ULocale[] TestLocales = {
    557             new ULocale("en_US@calendar=gregorian"),
    558             new ULocale("ja_JP@calendar=japanese"),
    559             new ULocale("th_TH@calendar=buddhist"),
    560             new ULocale("zh_TW@calendar=roc"),
    561             new ULocale("ar_IR@calendar=persian"),
    562             new ULocale("ar_EG@calendar=islamic"),
    563             new ULocale("he_IL@calendar=hebrew"),
    564             new ULocale("zh_CN@calendar=chinese"),
    565             new ULocale("hi_IN@calendar=indian"),
    566             new ULocale("ar_EG@calendar=coptic"),
    567             new ULocale("am_ET@calendar=ethiopic"),
    568         };
    569 
    570         int i;
    571 
    572         // calendars
    573         Calendar[] calendars = new Calendar[TestLocales.length];
    574         for (i = 0; i < TestLocales.length; i++) {
    575             calendars[i] = Calendar.getInstance(TestLocales[i]);
    576         }
    577 
    578         // Creates an instance from a base locale + calendar
    579         DateFormatSymbols[] symbols = new DateFormatSymbols[TestLocales.length];
    580         for (i = 0; i < TestLocales.length; i++) {
    581             symbols[i] = new DateFormatSymbols(calendars[i], new ULocale(TestLocales[i].getBaseName()));
    582         }
    583 
    584         // Compare an instance created from a base locale + calendar
    585         // with an instance created from its base locale + calendar class
    586         for (i = 0; i < TestLocales.length; i++) {
    587             DateFormatSymbols dfs = new DateFormatSymbols(calendars[i].getClass(), new ULocale(TestLocales[i].getBaseName()));
    588             if (!dfs.equals(symbols[i])) {
    589                 errln("FAIL: DateFormatSymbols created from a base locale and calendar instance"
    590                         + " is different from one created from the same base locale and calendar class - "
    591                         + TestLocales[i]);
    592             }
    593         }
    594 
    595     }
    596 }
    597