OSDN Git Service

パッケージ変更。テスト整備。
[mikutoga/TogaGem.git] / src / test / java / jp / sfjp / mikutoga / corelib / I18nTextTest.java
1 /*
2  */
3
4 package jp.sfjp.mikutoga.corelib;
5
6 import java.util.List;
7 import java.util.Locale;
8 import org.junit.After;
9 import org.junit.AfterClass;
10 import org.junit.Before;
11 import org.junit.BeforeClass;
12 import org.junit.Test;
13 import static org.junit.Assert.*;
14
15 /**
16  *
17  */
18 public class I18nTextTest {
19
20     public I18nTextTest() {
21     }
22
23     @BeforeClass
24     public static void setUpClass() {
25     }
26
27     @AfterClass
28     public static void tearDownClass() {
29     }
30
31     @Before
32     public void setUp() {
33     }
34
35     @After
36     public void tearDown() {
37     }
38
39     /**
40      * Test of setPrimaryText method, of class I18nText.
41      */
42     @Test
43     public void testSetPrimaryText() {
44         System.out.println("setPrimaryText");
45
46         I18nText text;
47
48         text = new I18nText();
49         text.setPrimaryText("pri");
50         assertEquals("pri", text.getPrimaryText());
51
52         text.setPrimaryText(null);
53         assertNull(text.getPrimaryText());
54
55         return;
56     }
57
58     /**
59      * Test of setGlobalText method, of class I18nText.
60      */
61     @Test
62     public void testSetGlobalText() {
63         System.out.println("setGlobalText");
64
65         I18nText text;
66
67         text = new I18nText();
68         text.setGlobalText("glo");
69
70         assertEquals("glo", text.getGlobalText());
71
72         text.setGlobalText(null);
73         assertNull(text.getGlobalText());
74
75         return;
76     }
77
78     /**
79      * Test of setI18nText method, of class I18nText.
80      */
81     @Test
82     public void testSetI18nText_Locale_CharSequence() {
83         System.out.println("setI18nText");
84
85         I18nText text;
86
87         text = new I18nText();
88         text.setI18nText(Locale.JAPANESE, "pri");
89         assertEquals("pri", text.getPrimaryText());
90
91         text.setI18nText(Locale.JAPANESE, null);
92         assertNull(text.getPrimaryText());
93
94         return;
95     }
96
97     /**
98      * Test of setI18nText method, of class I18nText.
99      */
100     @Test
101     public void testSetI18nText_String_CharSequence() {
102         System.out.println("setI18nText");
103
104         I18nText text;
105
106         text = new I18nText();
107         text.setI18nText("ja", "pri");
108         assertEquals("pri", text.getPrimaryText());
109
110         text.setI18nText("ja", null);
111         assertNull(text.getPrimaryText());
112
113         return;
114     }
115
116     /**
117      * Test of getPrimaryText method, of class I18nText.
118      */
119     @Test
120     public void testGetPrimaryText() {
121         System.out.println("getPrimaryText");
122
123         I18nText text;
124
125         text = new I18nText();
126         assertNull(text.getPrimaryText());
127
128         text.setPrimaryText("pri");
129         assertEquals("pri", text.getPrimaryText());
130
131         return;
132     }
133
134     /**
135      * Test of getGlobalText method, of class I18nText.
136      */
137     @Test
138     public void testGetGlobalText() {
139         System.out.println("getGlobalText");
140
141         I18nText text;
142
143         text = new I18nText();
144         assertNull(text.getGlobalText());
145
146         text.setGlobalText("glo");
147         assertEquals("glo", text.getGlobalText());
148
149         return;
150     }
151
152     /**
153      * Test of getI18nText method, of class I18nText.
154      */
155     @Test
156     public void testGetI18nText_Locale() {
157         System.out.println("getI18nText");
158
159         I18nText text;
160
161         text = new I18nText();
162         text.setPrimaryText("pri");
163
164         assertEquals("pri", text.getI18nText(Locale.JAPANESE));
165         assertNull(text.getI18nText(Locale.ENGLISH));
166
167         return;
168     }
169
170     /**
171      * Test of getI18nText method, of class I18nText.
172      */
173     @Test
174     public void testGetI18nText_String() {
175         System.out.println("getI18nText");
176
177         I18nText text;
178
179         text = new I18nText();
180         text.setPrimaryText("pri");
181
182         assertEquals("pri", text.getI18nText("ja"));
183         assertNull(text.getI18nText("en"));
184
185         return;
186     }
187
188     /**
189      * Test of getText method, of class I18nText.
190      */
191     @Test
192     public void testGetText() {
193         System.out.println("getText");
194
195         I18nText text;
196
197         text = new I18nText();
198         assertEquals("", text.getText());
199
200         text.setPrimaryText("pri");
201         assertEquals("pri", text.getText());
202
203         return;
204     }
205
206     /**
207      * Test of getLocalizedText method, of class I18nText.
208      */
209     @Test
210     public void testGetLocalizedText() {
211         System.out.println("getLocalizedText");
212
213         I18nText text;
214
215         text = new I18nText();
216         assertEquals("", text.getLocalizedText());
217
218         text = new I18nText();
219         text.setPrimaryText("pri");
220         assertEquals("pri", text.getLocalizedText());
221
222         text = new I18nText();
223         text.setGlobalText("glo");
224         assertEquals("glo", text.getLocalizedText());
225
226         text = new I18nText();
227         text.setI18nText(Locale.CHINESE, "chi");
228         assertEquals("chi", text.getLocalizedText());
229
230         // default locale...
231
232         return;
233     }
234
235     /**
236      * Test of clearI18nText method, of class I18nText.
237      */
238     @Test
239     public void testClearI18nText() {
240         System.out.println("clearI18nText");
241
242         I18nText text;
243
244         text = new I18nText();
245
246         text.setPrimaryText("pri");
247         text.setGlobalText("glo");
248
249         assertNotNull(text.getPrimaryText());
250         assertNotNull(text.getGlobalText());
251
252         text.clearI18nText();
253
254         assertNull(text.getPrimaryText());
255         assertNull(text.getGlobalText());
256
257         return;
258     }
259
260     /**
261      * Test of lang639CodeList method, of class I18nText.
262      */
263     @Test
264     public void testLang639CodeList() {
265         System.out.println("lang639CodeList");
266
267         I18nText text;
268         List<String> list;
269
270         text = new I18nText();
271
272         list = text.lang639CodeList();
273         assertTrue(list.isEmpty());
274
275         text.setI18nText(Locale.CHINA, "chi");
276         text.setPrimaryText("pri");
277         text.setGlobalText("glo");
278
279         list = text.lang639CodeList();
280
281         assertEquals(3, list.size());
282         assertEquals("ja", list.get(0));
283         assertEquals("en", list.get(1));
284         assertEquals("zh", list.get(2));
285
286         return;
287     }
288
289     /**
290      * Test of hasPrimaryText method, of class I18nText.
291      */
292     @Test
293     public void testHasPrimaryText() {
294         System.out.println("hasPrimaryText");
295
296         I18nText text;
297
298         text = new I18nText();
299         assertFalse(text.hasPrimaryText());
300
301         text.setPrimaryText("pri");
302         assertTrue(text.hasPrimaryText());
303
304         text.setPrimaryText(null);
305         assertFalse(text.hasPrimaryText());
306
307         text.setGlobalText("glo");
308         assertFalse(text.hasPrimaryText());
309
310         return;
311     }
312
313     /**
314      * Test of hasGlobalText method, of class I18nText.
315      */
316     @Test
317     public void testHasGlobalText() {
318         System.out.println("hasGlobalText");
319
320         I18nText text;
321
322         text = new I18nText();
323         assertFalse(text.hasGlobalText());
324
325         text.setGlobalText("glo");
326         assertTrue(text.hasGlobalText());
327
328         text.setGlobalText(null);
329         assertFalse(text.hasGlobalText());
330
331         text.setPrimaryText("pri");
332         assertFalse(text.hasGlobalText());
333
334         return;
335     }
336
337     /**
338      * Test of charAt method, of class I18nText.
339      */
340     @Test
341     public void testCharAt() {
342         System.out.println("charAt");
343
344         I18nText text;
345
346         text = new I18nText();
347
348         text.setPrimaryText("pri");
349         text.setGlobalText("glo");
350         text.setI18nText(Locale.CHINA, "chi");
351
352         assertEquals('r', text.charAt(1));
353
354         return;
355     }
356
357     /**
358      * Test of length method, of class I18nText.
359      */
360     @Test
361     public void testLength() {
362         System.out.println("length");
363
364         I18nText text;
365
366         text = new I18nText();
367
368         text.setPrimaryText("pri");
369         text.setGlobalText("glob");
370         text.setI18nText(Locale.CHINA, "china");
371
372         assertEquals(3, text.length());
373
374         return;
375     }
376
377     /**
378      * Test of subSequence method, of class I18nText.
379      */
380     @Test
381     public void testSubSequence() {
382         System.out.println("subSequence");
383
384         I18nText text;
385
386         text = new I18nText();
387
388         text.setPrimaryText("pri");
389         text.setGlobalText("glo");
390         text.setI18nText(Locale.CHINA, "chi");
391
392         assertEquals("p", text.subSequence(0, 1));
393
394         return;
395     }
396
397     /**
398      * Test of toString method, of class I18nText.
399      */
400     @Test
401     public void testToString() {
402         System.out.println("toString");
403
404         I18nText text;
405
406         text = new I18nText();
407
408         text.setPrimaryText("pri");
409         text.setGlobalText("glo");
410         text.setI18nText(Locale.CHINA, "chi");
411
412         assertEquals("pri", text.toString());
413
414         return;
415     }
416
417 }