Home | History | Annotate | Download | only in tests
      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) 2006-2011, International Business Machines Corporation and    *
      6  * others. All Rights Reserved.                                                *
      7  *******************************************************************************
      8  */
      9 
     10 package com.ibm.icu.tests;
     11 
     12 import java.util.Locale;
     13 
     14 import com.ibm.icu.text.DateFormatSymbols;
     15 import com.ibm.icu.util.ULocale;
     16 
     17 public class DateFormatSymbolsTest extends ICUTestCase {
     18 
     19     /*
     20      * Test method for 'com.ibm.icu.text.DateFormatSymbols.hashCode()'
     21      */
     22     public void testHashCode() {
     23         DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
     24         DateFormatSymbols dfs2 = new DateFormatSymbols(ULocale.US);
     25         DateFormatSymbols dfsn = new DateFormatSymbols(Locale.US);
     26         dfsn.setAmPmStrings(new String[] { "sw", "xw" });
     27         testEHCS(dfs, dfs2, dfsn);
     28     }
     29 
     30     /*
     31      * Test method for 'com.ibm.icu.text.DateFormatSymbols.DateFormatSymbols(DateFormatSymbols)'
     32      */
     33     public void testDateFormatSymbolsDateFormatSymbols() {
     34         // implicitly tested everywhere
     35     }
     36 
     37     /*
     38      * Test method for 'com.ibm.icu.text.DateFormatSymbols.DateFormatSymbols()'
     39      */
     40     public void testDateFormatSymbols() {
     41         DateFormatSymbols dfs = new DateFormatSymbols();
     42         assertNotNull(dfs.getWeekdays());
     43     }
     44 
     45     /*
     46      * Test method for 'com.ibm.icu.text.DateFormatSymbols.DateFormatSymbols(Locale)'
     47      */
     48     public void testDateFormatSymbolsLocale() {
     49         DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
     50         assertNotNull(dfs.getWeekdays());
     51     }
     52 
     53     /*
     54      * Test method for 'com.ibm.icu.text.DateFormatSymbols.DateFormatSymbols(ULocale)'
     55      */
     56     public void testDateFormatSymbolsULocale() {
     57         DateFormatSymbols dfs = new DateFormatSymbols(ULocale.US);
     58         assertNotNull(dfs.getWeekdays());
     59     }
     60 
     61     /*
     62      * Test method for 'com.ibm.icu.text.DateFormatSymbols.getEras()'
     63      */
     64     public void testGetEras() {
     65         DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
     66         assertNotNull(dfs.getEras());
     67     }
     68 
     69     /*
     70      * Test method for 'com.ibm.icu.text.DateFormatSymbols.setEras(String[])'
     71      */
     72     public void testSetEras() {
     73         DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
     74         String[] oldvalue = dfs.getEras();
     75         String[] newvalue = (String[])oldvalue.clone();
     76         newvalue[0] = newvalue[0] + "!";
     77         dfs.setEras(newvalue);
     78         String[] result = dfs.getEras();
     79         assertArraysNotEqual(oldvalue, result);
     80         assertArraysEqual(newvalue, result);
     81     }
     82 
     83     /*
     84      * Test method for 'com.ibm.icu.text.DateFormatSymbols.getMonths()'
     85      */
     86     public void testGetMonths() {
     87         DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
     88         assertNotNull(dfs.getMonths());
     89     }
     90 
     91     /*
     92      * Test method for 'com.ibm.icu.text.DateFormatSymbols.setMonths(String[])'
     93      */
     94     public void testSetMonths() {
     95         DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
     96         String[] oldvalue = dfs.getMonths();
     97         String[] newvalue = (String[])oldvalue.clone();
     98         newvalue[0] = newvalue[0] + "!";
     99         dfs.setMonths(newvalue);
    100         String[] result = dfs.getMonths();
    101         assertArraysNotEqual(oldvalue, result);
    102         assertArraysEqual(newvalue, result);
    103     }
    104 
    105     /*
    106      * Test method for 'com.ibm.icu.text.DateFormatSymbols.getShortMonths()'
    107      */
    108     public void testGetShortMonths() {
    109         DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
    110         assertNotNull(dfs.getShortMonths());
    111     }
    112 
    113     /*
    114      * Test method for 'com.ibm.icu.text.DateFormatSymbols.setShortMonths(String[])'
    115      */
    116     public void testSetShortMonths() {
    117         DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
    118         String[] oldvalue = dfs.getShortMonths();
    119         String[] newvalue = (String[])oldvalue.clone();
    120         newvalue[0] = newvalue[0] + "!";
    121         dfs.setShortMonths(newvalue);
    122         String[] result = dfs.getShortMonths();
    123         assertArraysNotEqual(oldvalue, result);
    124         assertArraysEqual(newvalue, result);
    125     }
    126 
    127     /*
    128      * Test method for 'com.ibm.icu.text.DateFormatSymbols.getWeekdays()'
    129      */
    130     public void testGetWeekdays() {
    131         DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
    132         assertNotNull(dfs.getShortMonths());
    133     }
    134 
    135     /*
    136      * Test method for 'com.ibm.icu.text.DateFormatSymbols.setWeekdays(String[])'
    137      */
    138     public void testSetWeekdays() {
    139         DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
    140         String[] oldvalue = dfs.getWeekdays();
    141         String[] newvalue = (String[])oldvalue.clone();
    142         newvalue[0] = newvalue[0] + "!";
    143         dfs.setWeekdays(newvalue);
    144         String[] result = dfs.getWeekdays();
    145         assertArraysNotEqual(oldvalue, result);
    146         assertArraysEqual(newvalue, result);
    147     }
    148 
    149     /*
    150      * Test method for 'com.ibm.icu.text.DateFormatSymbols.getShortWeekdays()'
    151      */
    152     public void testGetShortWeekdays() {
    153         DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
    154         assertNotNull(dfs.getShortWeekdays());
    155     }
    156 
    157     /*
    158      * Test method for 'com.ibm.icu.text.DateFormatSymbols.setShortWeekdays(String[])'
    159      */
    160     public void testSetShortWeekdays() {
    161         DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
    162         String[] oldvalue = dfs.getShortWeekdays();
    163         String[] newvalue = (String[])oldvalue.clone();
    164         newvalue[0] = newvalue[0] + "!";
    165         dfs.setShortWeekdays(newvalue);
    166         String[] result = dfs.getShortWeekdays();
    167         assertArraysNotEqual(oldvalue, result);
    168         assertArraysEqual(newvalue, result);
    169     }
    170 
    171     /*
    172      * Test method for 'com.ibm.icu.text.DateFormatSymbols.getAmPmStrings()'
    173      */
    174     public void testGetAmPmStrings() {
    175         DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
    176         assertNotNull(dfs.getAmPmStrings());
    177     }
    178 
    179     /*
    180      * Test method for 'com.ibm.icu.text.DateFormatSymbols.setAmPmStrings(String[])'
    181      */
    182     public void testSetAmPmStrings() {
    183         DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
    184         String[] oldvalue = dfs.getAmPmStrings();
    185         String[] newvalue = (String[])oldvalue.clone();
    186         newvalue[0] = newvalue[0] + "!";
    187         dfs.setAmPmStrings(newvalue);
    188         String[] result = dfs.getAmPmStrings();
    189         assertArraysNotEqual(oldvalue, result);
    190         assertArraysEqual(newvalue, result);
    191     }
    192 
    193     /*
    194      * Test method for 'com.ibm.icu.text.DateFormatSymbols.getZoneStrings()'
    195      */
    196     public void testGetZoneStrings() {
    197         DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
    198         assertNotNull(dfs.getZoneStrings());
    199     }
    200 
    201     /*
    202      * Test method for 'com.ibm.icu.text.DateFormatSymbols.setZoneStrings(String[][])'
    203      */
    204     public void testSetZoneStrings() {
    205         DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
    206         String[][] oldvalue = dfs.getZoneStrings();
    207         String[][] newvalue = (String[][])cloneComplex(oldvalue);
    208         newvalue[0][0] = newvalue[0][0] + "!";
    209         dfs.setZoneStrings(newvalue);
    210         String[][] result = dfs.getZoneStrings();
    211         assertArraysNotEqual(oldvalue, result);
    212         assertArraysEqual(newvalue, result);
    213     }
    214 
    215     /*
    216      * Test method for 'com.ibm.icu.text.DateFormatSymbols.getLocalPatternChars()'
    217      */
    218     public void testGetLocalPatternChars() {
    219         DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
    220         assertNotNull(dfs.getLocalPatternChars());
    221     }
    222 
    223     /*
    224      * Test method for 'com.ibm.icu.text.DateFormatSymbols.setLocalPatternChars(String)'
    225      */
    226     public void testSetLocalPatternChars() {
    227         DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
    228         String pat = dfs.getLocalPatternChars();
    229         StringBuffer buf = new StringBuffer(pat);
    230         buf.setCharAt(0, (char)(pat.charAt(0) + 1));
    231         String pat2 = buf.toString();
    232         dfs.setLocalPatternChars(pat2);
    233         String pat3 = dfs.getLocalPatternChars();
    234         assertNotEqual(pat, pat2);
    235         assertEquals(pat2, pat3);
    236     }
    237 
    238     /*
    239      * Test method for 'com.ibm.icu.text.DateFormatSymbols.toString()'
    240      */
    241     public void testToString() {
    242         DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
    243         assertNotNull(dfs.toString());
    244     }
    245 
    246     /*
    247      * Test method for 'com.ibm.icu.text.DateFormatSymbols.clone()'
    248      */
    249     public void testClone() {
    250         // tested by testHashCode
    251     }
    252 
    253     /*
    254      * Test method for 'com.ibm.icu.text.DateFormatSymbols.equals(Object)'
    255      */
    256     public void testEqualsObject() {
    257         // tested by testHashCode
    258     }
    259 }
    260