summaryrefslogtreecommitdiffstats
path: root/luni/src/test/java/libcore/icu/LocaleDataTest.java
blob: e412a1d360d88fd94b659cf4afa1708a98a47da5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
 * Copyright (C) 2012 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package libcore.icu;

import java.util.Locale;

public class LocaleDataTest extends junit.framework.TestCase {
    public void testAll() throws Exception {
        // Test that we can get the locale data for all known locales.
        for (Locale l : Locale.getAvailableLocales()) {
            LocaleData d = LocaleData.get(l);
            System.err.println(l + " : " + d.yesterday + " " + d.today + " " + d.tomorrow);
        }
    }

    public void test_en_US() throws Exception {
        LocaleData l = LocaleData.get(Locale.US);
        assertEquals("AM", l.amPm[0]);
        assertEquals("BC", l.eras[0]);

        assertEquals("January", l.longMonthNames[0]);
        assertEquals("Jan", l.shortMonthNames[0]);
        assertEquals("J", l.tinyMonthNames[0]);

        assertEquals("January", l.longStandAloneMonthNames[0]);
        assertEquals("Jan", l.shortStandAloneMonthNames[0]);
        assertEquals("J", l.tinyStandAloneMonthNames[0]);

        assertEquals("Sunday", l.longWeekdayNames[1]);
        assertEquals("Sun", l.shortWeekdayNames[1]);
        assertEquals("S", l.tinyWeekdayNames[1]);

        assertEquals("Sunday", l.longStandAloneWeekdayNames[1]);
        assertEquals("Sun", l.shortStandAloneWeekdayNames[1]);
        assertEquals("S", l.tinyStandAloneWeekdayNames[1]);

        assertEquals("Yesterday", l.yesterday);
        assertEquals("Today", l.today);
        assertEquals("Tomorrow", l.tomorrow);
    }

    public void test_de_DE() throws Exception {
        LocaleData l = LocaleData.get(new Locale("de", "DE"));

        assertEquals("Gestern", l.yesterday);
        assertEquals("Heute", l.today);
        assertEquals("Morgen", l.tomorrow);
    }

    public void test_cs_CZ() throws Exception {
        LocaleData l = LocaleData.get(new Locale("cs", "CZ"));

        assertEquals("ledna", l.longMonthNames[0]);
        assertEquals("Led", l.shortMonthNames[0]);
        assertEquals("1", l.tinyMonthNames[0]);

        assertEquals("leden", l.longStandAloneMonthNames[0]);
        assertEquals("1.", l.shortStandAloneMonthNames[0]);
        assertEquals("l", l.tinyStandAloneMonthNames[0]);
    }

    public void test_ru_RU() throws Exception {
        LocaleData l = LocaleData.get(new Locale("ru", "RU"));

        assertEquals("воскресенье", l.longWeekdayNames[1]);
        assertEquals("вс", l.shortWeekdayNames[1]);
        assertEquals("В", l.tinyWeekdayNames[1]);

        // Russian stand-alone weekday names get an initial capital.
        assertEquals("Воскресенье", l.longStandAloneWeekdayNames[1]);
        assertEquals("Вс", l.shortStandAloneWeekdayNames[1]);
        assertEquals("В", l.tinyStandAloneWeekdayNames[1]);
    }
}