• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /********************************************************************
2  * COPYRIGHT:
3  * Copyright (c) 1997-2010, International Business Machines Corporation and
4  * others. All Rights Reserved.
5  ********************************************************************/
6 
7 #include "intltest.h"
8 #include "unicode/locid.h"
9 
10 /**
11  * Tests for the Locale class
12  **/
13 class LocaleTest: public IntlTest {
14 public:
15     LocaleTest();
16     virtual ~LocaleTest();
17 
18     void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par = NULL );
19 
20     /**
21      * Test methods to set and get data fields
22      **/
23     void TestBasicGetters(void);
24     /**
25      * Test methods to set and get data fields
26      **/
27     void TestParallelAPIValues(void);
28     /**
29      * Use Locale to access Resource file data and compare against expected values
30      **/
31     void TestSimpleResourceInfo(void);
32     /**
33      * Use Locale to access Resource file display names and compare against expected values
34      **/
35     void TestDisplayNames(void);
36     /**
37      * Test methods for basic object behaviour
38      **/
39     void TestSimpleObjectStuff(void);
40     /**
41      * Test methods for POSIX parsing behavior
42      **/
43     void TestPOSIXParsing(void);
44     /**
45      * Test Locale::getAvailableLocales
46      **/
47     void TestGetAvailableLocales(void);
48     /**
49      * Test methods to set and access a custom data directory
50      **/
51     void TestDataDirectory(void);
52 
53     void TestISO3Fallback(void);
54     void TestGetLangsAndCountries(void);
55     void TestSimpleDisplayNames(void);
56     void TestUninstalledISO3Names(void);
57     void TestAtypicalLocales(void);
58 #if !UCONFIG_NO_FORMATTING
59     void TestThaiCurrencyFormat(void);
60     void TestEuroSupport(void);
61 #endif
62     void TestToString(void);
63 #if !UCONFIG_NO_FORMATTING
64     void Test4139940(void);
65     void Test4143951(void);
66 #endif
67     void Test4147315(void);
68     void Test4147317(void);
69     void Test4147552(void);
70 
71     void TestVariantParsing(void);
72 
73    /* Test getting keyword enumeratin */
74    void TestKeywordVariants(void);
75 
76    /* Test getting keyword values */
77    void TestKeywordVariantParsing(void);
78 
79    /* Test setting keyword values */
80    void TestSetKeywordValue(void);
81 
82    /* Test getting the locale base name */
83    void TestGetBaseName(void);
84     void TestTrailingNull(void);  /* Google Patch */
85 
86 #if !UCONFIG_NO_FORMATTING
87     void Test4105828(void) ;
88 #endif
89 
90     void TestSetIsBogus(void);
91 
92     void TestGetLocale(void);
93 
94     void TestVariantWithOutCountry(void);
95 
96     void TestCanonicalization(void);
97 
98 #if !UCONFIG_NO_FORMATTING
99     static UDate date(int32_t y, int32_t m, int32_t d, int32_t hr = 0, int32_t min = 0, int32_t sec = 0);
100 #endif
101 
102     void TestCurrencyByDate(void);
103 
104     void TestGetVariantWithKeywords(void);
105 
106 private:
107     void _checklocs(const char* label,
108                     const char* req,
109                     const Locale& validLoc,
110                     const Locale& actualLoc,
111                     const char* expReqValid="gt",
112                     const char* expValidActual="ge");
113 
114     /**
115      * routine to perform subtests, used by TestDisplayNames
116      **/
117     void doTestDisplayNames(Locale& inLocale, int32_t compareIndex);
118     /**
119      * additional intialization for datatables storing expected values
120      **/
121     void setUpDataTable(void);
122 
123     UnicodeString** dataTable;
124 
125     enum {
126         ENGLISH = 0,
127         FRENCH = 1,
128         CROATIAN = 2,
129         GREEK = 3,
130         NORWEGIAN = 4,
131         ITALIAN = 5,
132         XX = 6,
133         CHINESE = 7,
134         MAX_LOCALES = 7
135     };
136 
137     enum {
138         LANG = 0,
139         SCRIPT,
140         CTRY,
141         VAR,
142         NAME,
143         LANG3,
144         CTRY3,
145         LCID,
146         DLANG_EN,
147         DSCRIPT_EN,
148         DCTRY_EN,
149         DVAR_EN,
150         DNAME_EN,
151         DLANG_FR,
152         DSCRIPT_FR,
153         DCTRY_FR,
154         DVAR_FR,
155         DNAME_FR,
156         DLANG_CA,
157         DSCRIPT_CA,
158         DCTRY_CA,
159         DVAR_CA,
160         DNAME_CA,
161         DLANG_EL,
162         DSCRIPT_EL,
163         DCTRY_EL,
164         DVAR_EL,
165         DNAME_EL,
166         DLANG_NO,
167         DSCRIPT_NO,
168         DCTRY_NO,
169         DVAR_NO,
170         DNAME_NO
171     };
172 };
173 
174 
175 
176 
177