1/********************************************************************
2 * COPYRIGHT:
3 * Copyright (c) 1997-2015, 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 **/
13class LocaleTest: public IntlTest {
14public:
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
85#if !UCONFIG_NO_FORMATTING
86    void Test4105828(void) ;
87#endif
88
89    void TestSetIsBogus(void);
90
91    void TestGetLocale(void);
92
93    void TestVariantWithOutCountry(void);
94
95    void TestCanonicalization(void);
96
97#if !UCONFIG_NO_FORMATTING
98    static UDate date(int32_t y, int32_t m, int32_t d, int32_t hr = 0, int32_t min = 0, int32_t sec = 0);
99#endif
100
101    void TestCurrencyByDate(void);
102
103    void TestGetVariantWithKeywords(void);
104    void TestIsRightToLeft();
105    void TestBug11421();
106
107private:
108    void _checklocs(const char* label,
109                    const char* req,
110                    const Locale& validLoc,
111                    const Locale& actualLoc,
112                    const char* expReqValid="gt",
113                    const char* expValidActual="ge");
114
115    /**
116     * routine to perform subtests, used by TestDisplayNames
117     **/
118    void doTestDisplayNames(Locale& inLocale, int32_t compareIndex);
119    /**
120     * additional intialization for datatables storing expected values
121     **/
122    void setUpDataTable(void);
123
124    UnicodeString** dataTable;
125
126    enum {
127        ENGLISH = 0,
128        FRENCH = 1,
129        CROATIAN = 2,
130        GREEK = 3,
131        NORWEGIAN = 4,
132        ITALIAN = 5,
133        XX = 6,
134        CHINESE = 7,
135        MAX_LOCALES = 7
136    };
137
138    enum {
139        LANG = 0,
140        SCRIPT,
141        CTRY,
142        VAR,
143        NAME,
144        LANG3,
145        CTRY3,
146        LCID,
147        DLANG_EN,
148        DSCRIPT_EN,
149        DCTRY_EN,
150        DVAR_EN,
151        DNAME_EN,
152        DLANG_FR,
153        DSCRIPT_FR,
154        DCTRY_FR,
155        DVAR_FR,
156        DNAME_FR,
157        DLANG_CA,
158        DSCRIPT_CA,
159        DCTRY_CA,
160        DVAR_CA,
161        DNAME_CA,
162        DLANG_EL,
163        DSCRIPT_EL,
164        DCTRY_EL,
165        DVAR_EL,
166        DNAME_EL,
167        DLANG_NO,
168        DSCRIPT_NO,
169        DCTRY_NO,
170        DVAR_NO,
171        DNAME_NO
172    };
173
174#if !UCONFIG_NO_COLLATION
175    /**
176     * Check on registered collators.
177     * @param expectExtra if non-null, the locale ID of an 'extra' locale that is registered.
178     */
179    void checkRegisteredCollators(const char *expectExtra = NULL);
180#endif
181};
182