xref: /aosp_15_r20/external/icu/icu4c/source/test/intltest/loctest.h (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
1*0e209d39SAndroid Build Coastguard Worker // © 2016 and later: Unicode, Inc. and others.
2*0e209d39SAndroid Build Coastguard Worker // License & terms of use: http://www.unicode.org/copyright.html
3*0e209d39SAndroid Build Coastguard Worker /********************************************************************
4*0e209d39SAndroid Build Coastguard Worker  * COPYRIGHT:
5*0e209d39SAndroid Build Coastguard Worker  * Copyright (c) 1997-2015, International Business Machines Corporation and
6*0e209d39SAndroid Build Coastguard Worker  * others. All Rights Reserved.
7*0e209d39SAndroid Build Coastguard Worker  ********************************************************************/
8*0e209d39SAndroid Build Coastguard Worker 
9*0e209d39SAndroid Build Coastguard Worker #include "intltest.h"
10*0e209d39SAndroid Build Coastguard Worker #include "unicode/locid.h"
11*0e209d39SAndroid Build Coastguard Worker 
12*0e209d39SAndroid Build Coastguard Worker /**
13*0e209d39SAndroid Build Coastguard Worker  * Tests for the Locale class
14*0e209d39SAndroid Build Coastguard Worker  **/
15*0e209d39SAndroid Build Coastguard Worker class LocaleTest: public IntlTest {
16*0e209d39SAndroid Build Coastguard Worker public:
17*0e209d39SAndroid Build Coastguard Worker     LocaleTest();
18*0e209d39SAndroid Build Coastguard Worker     virtual ~LocaleTest();
19*0e209d39SAndroid Build Coastguard Worker 
20*0e209d39SAndroid Build Coastguard Worker     void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par = nullptr ) override;
21*0e209d39SAndroid Build Coastguard Worker 
22*0e209d39SAndroid Build Coastguard Worker     /**
23*0e209d39SAndroid Build Coastguard Worker      * Test methods to set and get data fields
24*0e209d39SAndroid Build Coastguard Worker      **/
25*0e209d39SAndroid Build Coastguard Worker     void TestBasicGetters();
26*0e209d39SAndroid Build Coastguard Worker     void TestVariantLengthLimit();
27*0e209d39SAndroid Build Coastguard Worker     /**
28*0e209d39SAndroid Build Coastguard Worker      * Test methods to set and get data fields
29*0e209d39SAndroid Build Coastguard Worker      **/
30*0e209d39SAndroid Build Coastguard Worker     void TestParallelAPIValues();
31*0e209d39SAndroid Build Coastguard Worker     /**
32*0e209d39SAndroid Build Coastguard Worker      * Use Locale to access Resource file data and compare against expected values
33*0e209d39SAndroid Build Coastguard Worker      **/
34*0e209d39SAndroid Build Coastguard Worker     void TestSimpleResourceInfo();
35*0e209d39SAndroid Build Coastguard Worker     /**
36*0e209d39SAndroid Build Coastguard Worker      * Use Locale to access Resource file display names and compare against expected values
37*0e209d39SAndroid Build Coastguard Worker      **/
38*0e209d39SAndroid Build Coastguard Worker     void TestDisplayNames();
39*0e209d39SAndroid Build Coastguard Worker     /**
40*0e209d39SAndroid Build Coastguard Worker      * Test methods for basic object behaviour
41*0e209d39SAndroid Build Coastguard Worker      **/
42*0e209d39SAndroid Build Coastguard Worker     void TestSimpleObjectStuff();
43*0e209d39SAndroid Build Coastguard Worker     /**
44*0e209d39SAndroid Build Coastguard Worker      * Test methods for POSIX parsing behavior
45*0e209d39SAndroid Build Coastguard Worker      **/
46*0e209d39SAndroid Build Coastguard Worker     void TestPOSIXParsing();
47*0e209d39SAndroid Build Coastguard Worker     /**
48*0e209d39SAndroid Build Coastguard Worker      * Test Locale::getAvailableLocales
49*0e209d39SAndroid Build Coastguard Worker      **/
50*0e209d39SAndroid Build Coastguard Worker     void TestGetAvailableLocales();
51*0e209d39SAndroid Build Coastguard Worker     /**
52*0e209d39SAndroid Build Coastguard Worker      * Test methods to set and access a custom data directory
53*0e209d39SAndroid Build Coastguard Worker      **/
54*0e209d39SAndroid Build Coastguard Worker     void TestDataDirectory();
55*0e209d39SAndroid Build Coastguard Worker 
56*0e209d39SAndroid Build Coastguard Worker     void TestISO3Fallback();
57*0e209d39SAndroid Build Coastguard Worker     void TestGetLangsAndCountries();
58*0e209d39SAndroid Build Coastguard Worker     void TestSimpleDisplayNames();
59*0e209d39SAndroid Build Coastguard Worker     void TestUninstalledISO3Names();
60*0e209d39SAndroid Build Coastguard Worker     void TestAtypicalLocales();
61*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_FORMATTING
62*0e209d39SAndroid Build Coastguard Worker     void TestThaiCurrencyFormat();
63*0e209d39SAndroid Build Coastguard Worker     void TestEuroSupport();
64*0e209d39SAndroid Build Coastguard Worker #endif
65*0e209d39SAndroid Build Coastguard Worker     void TestToString();
66*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_FORMATTING
67*0e209d39SAndroid Build Coastguard Worker     void Test4139940();
68*0e209d39SAndroid Build Coastguard Worker     void Test4143951();
69*0e209d39SAndroid Build Coastguard Worker #endif
70*0e209d39SAndroid Build Coastguard Worker     void Test4147315();
71*0e209d39SAndroid Build Coastguard Worker     void Test4147317();
72*0e209d39SAndroid Build Coastguard Worker     void Test4147552();
73*0e209d39SAndroid Build Coastguard Worker 
74*0e209d39SAndroid Build Coastguard Worker     void Test20639_DeprecatesISO3Language();
75*0e209d39SAndroid Build Coastguard Worker 
76*0e209d39SAndroid Build Coastguard Worker     void TestVariantParsing();
77*0e209d39SAndroid Build Coastguard Worker 
78*0e209d39SAndroid Build Coastguard Worker    /* Test getting keyword enumeration */
79*0e209d39SAndroid Build Coastguard Worker    void TestKeywordVariants();
80*0e209d39SAndroid Build Coastguard Worker    void TestCreateUnicodeKeywords();
81*0e209d39SAndroid Build Coastguard Worker 
82*0e209d39SAndroid Build Coastguard Worker    /* Test getting keyword values */
83*0e209d39SAndroid Build Coastguard Worker    void TestKeywordVariantParsing();
84*0e209d39SAndroid Build Coastguard Worker    void TestCreateKeywordSet();
85*0e209d39SAndroid Build Coastguard Worker    void TestCreateKeywordSetEmpty();
86*0e209d39SAndroid Build Coastguard Worker    void TestCreateKeywordSetWithPrivateUse();
87*0e209d39SAndroid Build Coastguard Worker    void TestCreateUnicodeKeywordSet();
88*0e209d39SAndroid Build Coastguard Worker    void TestCreateUnicodeKeywordSetEmpty();
89*0e209d39SAndroid Build Coastguard Worker    void TestCreateUnicodeKeywordSetWithPrivateUse();
90*0e209d39SAndroid Build Coastguard Worker    void TestGetKeywordValueStdString();
91*0e209d39SAndroid Build Coastguard Worker    void TestGetUnicodeKeywordValueStdString();
92*0e209d39SAndroid Build Coastguard Worker 
93*0e209d39SAndroid Build Coastguard Worker    /* Test setting keyword values */
94*0e209d39SAndroid Build Coastguard Worker    void TestSetKeywordValue();
95*0e209d39SAndroid Build Coastguard Worker    void TestSetKeywordValueStringPiece();
96*0e209d39SAndroid Build Coastguard Worker    void TestSetUnicodeKeywordValueStringPiece();
97*0e209d39SAndroid Build Coastguard Worker 
98*0e209d39SAndroid Build Coastguard Worker    /* Test getting the locale base name */
99*0e209d39SAndroid Build Coastguard Worker    void TestGetBaseName();
100*0e209d39SAndroid Build Coastguard Worker 
101*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_FORMATTING
102*0e209d39SAndroid Build Coastguard Worker     void Test4105828() ;
103*0e209d39SAndroid Build Coastguard Worker #endif
104*0e209d39SAndroid Build Coastguard Worker 
105*0e209d39SAndroid Build Coastguard Worker     void TestSetIsBogus();
106*0e209d39SAndroid Build Coastguard Worker 
107*0e209d39SAndroid Build Coastguard Worker     void TestGetLocale();
108*0e209d39SAndroid Build Coastguard Worker 
109*0e209d39SAndroid Build Coastguard Worker     void TestVariantWithOutCountry();
110*0e209d39SAndroid Build Coastguard Worker 
111*0e209d39SAndroid Build Coastguard Worker     void TestCanonicalization();
112*0e209d39SAndroid Build Coastguard Worker 
113*0e209d39SAndroid Build Coastguard Worker     void TestCanonicalize();
114*0e209d39SAndroid Build Coastguard Worker 
115*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_FORMATTING
116*0e209d39SAndroid Build Coastguard Worker     static UDate date(int32_t y, int32_t m, int32_t d, int32_t hr = 0, int32_t min = 0, int32_t sec = 0);
117*0e209d39SAndroid Build Coastguard Worker #endif
118*0e209d39SAndroid Build Coastguard Worker 
119*0e209d39SAndroid Build Coastguard Worker     void TestCurrencyByDate();
120*0e209d39SAndroid Build Coastguard Worker 
121*0e209d39SAndroid Build Coastguard Worker     void TestGetVariantWithKeywords();
122*0e209d39SAndroid Build Coastguard Worker     void TestIsRightToLeft();
123*0e209d39SAndroid Build Coastguard Worker     void TestBug11421();
124*0e209d39SAndroid Build Coastguard Worker     void TestBug13277();
125*0e209d39SAndroid Build Coastguard Worker     void TestBug13554();
126*0e209d39SAndroid Build Coastguard Worker     void TestBug20410();
127*0e209d39SAndroid Build Coastguard Worker     void TestBug20900();
128*0e209d39SAndroid Build Coastguard Worker     void TestLocaleCanonicalizationFromFile();
129*0e209d39SAndroid Build Coastguard Worker     void TestKnownCanonicalizedListCorrect();
130*0e209d39SAndroid Build Coastguard Worker     void TestConstructorAcceptsBCP47();
131*0e209d39SAndroid Build Coastguard Worker 
132*0e209d39SAndroid Build Coastguard Worker     void TestPseudoLocales();
133*0e209d39SAndroid Build Coastguard Worker     void TestAddLikelySubtags();
134*0e209d39SAndroid Build Coastguard Worker     void TestMinimizeSubtags();
135*0e209d39SAndroid Build Coastguard Worker     void TestAddLikelyAndMinimizeSubtags();
136*0e209d39SAndroid Build Coastguard Worker     void TestDataDrivenLikelySubtags();
137*0e209d39SAndroid Build Coastguard Worker 
138*0e209d39SAndroid Build Coastguard Worker     void TestForLanguageTag();
139*0e209d39SAndroid Build Coastguard Worker     void TestForLanguageTagLegacyTagBug21676();
140*0e209d39SAndroid Build Coastguard Worker     void TestToLanguageTag();
141*0e209d39SAndroid Build Coastguard Worker     void TestToLanguageTagOmitTrue();
142*0e209d39SAndroid Build Coastguard Worker 
143*0e209d39SAndroid Build Coastguard Worker     void TestMoveAssign();
144*0e209d39SAndroid Build Coastguard Worker     void TestMoveCtor();
145*0e209d39SAndroid Build Coastguard Worker 
146*0e209d39SAndroid Build Coastguard Worker     void TestBug20407iVariantPreferredValue();
147*0e209d39SAndroid Build Coastguard Worker 
148*0e209d39SAndroid Build Coastguard Worker     void TestBug13417VeryLongLanguageTag();
149*0e209d39SAndroid Build Coastguard Worker 
150*0e209d39SAndroid Build Coastguard Worker     void TestBug11053UnderlineTimeZone();
151*0e209d39SAndroid Build Coastguard Worker 
152*0e209d39SAndroid Build Coastguard Worker     void TestUnd();
153*0e209d39SAndroid Build Coastguard Worker     void TestUndScript();
154*0e209d39SAndroid Build Coastguard Worker     void TestUndRegion();
155*0e209d39SAndroid Build Coastguard Worker     void TestUndCAPI();
156*0e209d39SAndroid Build Coastguard Worker     void TestRangeIterator();
157*0e209d39SAndroid Build Coastguard Worker     void TestPointerConvertingIterator();
158*0e209d39SAndroid Build Coastguard Worker     void TestTagConvertingIterator();
159*0e209d39SAndroid Build Coastguard Worker     void TestCapturingTagConvertingIterator();
160*0e209d39SAndroid Build Coastguard Worker     void TestSetUnicodeKeywordValueInLongLocale();
161*0e209d39SAndroid Build Coastguard Worker     void TestSetUnicodeKeywordValueNullInLongLocale();
162*0e209d39SAndroid Build Coastguard Worker     void TestLeak21419();
163*0e209d39SAndroid Build Coastguard Worker     void TestNullDereferenceWrite21597();
164*0e209d39SAndroid Build Coastguard Worker     void TestLongLocaleSetKeywordAssign();
165*0e209d39SAndroid Build Coastguard Worker     void TestLongLocaleSetKeywordMoveAssign();
166*0e209d39SAndroid Build Coastguard Worker     void TestSierraLeoneCurrency21997();
167*0e209d39SAndroid Build Coastguard Worker 
168*0e209d39SAndroid Build Coastguard Worker private:
169*0e209d39SAndroid Build Coastguard Worker     void _checklocs(const char* label,
170*0e209d39SAndroid Build Coastguard Worker                     const char* req,
171*0e209d39SAndroid Build Coastguard Worker                     const Locale& validLoc,
172*0e209d39SAndroid Build Coastguard Worker                     const Locale& actualLoc,
173*0e209d39SAndroid Build Coastguard Worker                     const char* expReqValid="gt",
174*0e209d39SAndroid Build Coastguard Worker                     const char* expValidActual="ge");
175*0e209d39SAndroid Build Coastguard Worker 
176*0e209d39SAndroid Build Coastguard Worker     /**
177*0e209d39SAndroid Build Coastguard Worker      * routine to perform subtests, used by TestDisplayNames
178*0e209d39SAndroid Build Coastguard Worker      **/
179*0e209d39SAndroid Build Coastguard Worker     void doTestDisplayNames(Locale& inLocale, int32_t compareIndex);
180*0e209d39SAndroid Build Coastguard Worker     /**
181*0e209d39SAndroid Build Coastguard Worker      * additional initialization for datatables storing expected values
182*0e209d39SAndroid Build Coastguard Worker      **/
183*0e209d39SAndroid Build Coastguard Worker     void setUpDataTable();
184*0e209d39SAndroid Build Coastguard Worker 
185*0e209d39SAndroid Build Coastguard Worker     UnicodeString** dataTable;
186*0e209d39SAndroid Build Coastguard Worker 
187*0e209d39SAndroid Build Coastguard Worker     enum {
188*0e209d39SAndroid Build Coastguard Worker         ENGLISH = 0,
189*0e209d39SAndroid Build Coastguard Worker         FRENCH = 1,
190*0e209d39SAndroid Build Coastguard Worker         CROATIAN = 2,
191*0e209d39SAndroid Build Coastguard Worker         GREEK = 3,
192*0e209d39SAndroid Build Coastguard Worker         NORWEGIAN = 4,
193*0e209d39SAndroid Build Coastguard Worker         ITALIAN = 5,
194*0e209d39SAndroid Build Coastguard Worker         XX = 6,
195*0e209d39SAndroid Build Coastguard Worker         CHINESE = 7,
196*0e209d39SAndroid Build Coastguard Worker         MAX_LOCALES = 7
197*0e209d39SAndroid Build Coastguard Worker     };
198*0e209d39SAndroid Build Coastguard Worker 
199*0e209d39SAndroid Build Coastguard Worker     enum {
200*0e209d39SAndroid Build Coastguard Worker         LANG = 0,
201*0e209d39SAndroid Build Coastguard Worker         SCRIPT,
202*0e209d39SAndroid Build Coastguard Worker         CTRY,
203*0e209d39SAndroid Build Coastguard Worker         VAR,
204*0e209d39SAndroid Build Coastguard Worker         NAME,
205*0e209d39SAndroid Build Coastguard Worker         LANG3,
206*0e209d39SAndroid Build Coastguard Worker         CTRY3,
207*0e209d39SAndroid Build Coastguard Worker         LCID,
208*0e209d39SAndroid Build Coastguard Worker         DLANG_EN,
209*0e209d39SAndroid Build Coastguard Worker         DSCRIPT_EN,
210*0e209d39SAndroid Build Coastguard Worker         DCTRY_EN,
211*0e209d39SAndroid Build Coastguard Worker         DVAR_EN,
212*0e209d39SAndroid Build Coastguard Worker         DNAME_EN,
213*0e209d39SAndroid Build Coastguard Worker         DLANG_FR,
214*0e209d39SAndroid Build Coastguard Worker         DSCRIPT_FR,
215*0e209d39SAndroid Build Coastguard Worker         DCTRY_FR,
216*0e209d39SAndroid Build Coastguard Worker         DVAR_FR,
217*0e209d39SAndroid Build Coastguard Worker         DNAME_FR,
218*0e209d39SAndroid Build Coastguard Worker         DLANG_CA,
219*0e209d39SAndroid Build Coastguard Worker         DSCRIPT_CA,
220*0e209d39SAndroid Build Coastguard Worker         DCTRY_CA,
221*0e209d39SAndroid Build Coastguard Worker         DVAR_CA,
222*0e209d39SAndroid Build Coastguard Worker         DNAME_CA,
223*0e209d39SAndroid Build Coastguard Worker         DLANG_EL,
224*0e209d39SAndroid Build Coastguard Worker         DSCRIPT_EL,
225*0e209d39SAndroid Build Coastguard Worker         DCTRY_EL,
226*0e209d39SAndroid Build Coastguard Worker         DVAR_EL,
227*0e209d39SAndroid Build Coastguard Worker         DNAME_EL,
228*0e209d39SAndroid Build Coastguard Worker         DLANG_NO,
229*0e209d39SAndroid Build Coastguard Worker         DSCRIPT_NO,
230*0e209d39SAndroid Build Coastguard Worker         DCTRY_NO,
231*0e209d39SAndroid Build Coastguard Worker         DVAR_NO,
232*0e209d39SAndroid Build Coastguard Worker         DNAME_NO
233*0e209d39SAndroid Build Coastguard Worker     };
234*0e209d39SAndroid Build Coastguard Worker 
235*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_COLLATION
236*0e209d39SAndroid Build Coastguard Worker     /**
237*0e209d39SAndroid Build Coastguard Worker      * Check on registered collators.
238*0e209d39SAndroid Build Coastguard Worker      * @param expectExtra if non-null, the locale ID of an 'extra' locale that is registered.
239*0e209d39SAndroid Build Coastguard Worker      */
240*0e209d39SAndroid Build Coastguard Worker     void checkRegisteredCollators(const char *expectExtra = nullptr);
241*0e209d39SAndroid Build Coastguard Worker #endif
242*0e209d39SAndroid Build Coastguard Worker };
243