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