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