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 TestConstructorAcceptsBCP47(); 126 127 void TestAddLikelySubtags(); 128 void TestMinimizeSubtags(); 129 void TestAddLikelyAndMinimizeSubtags(); 130 131 void TestForLanguageTag(); 132 void TestToLanguageTag(); 133 void TestToLanguageTagOmitTrue(); 134 135 void TestMoveAssign(); 136 void TestMoveCtor(); 137 138 void TestBug20407iVariantPreferredValue(); 139 140 void TestBug13417VeryLongLanguageTag(); 141 142 void TestBug11053UnderlineTimeZone(); 143 144 void TestUnd(); 145 void TestUndScript(); 146 void TestUndRegion(); 147 void TestUndCAPI(); 148 void TestRangeIterator(); 149 void TestPointerConvertingIterator(); 150 void TestTagConvertingIterator(); 151 void TestCapturingTagConvertingIterator(); 152 void TestSetUnicodeKeywordValueInLongLocale(); 153 void TestSetUnicodeKeywordValueNullInLongLocale(); 154 155 private: 156 void _checklocs(const char* label, 157 const char* req, 158 const Locale& validLoc, 159 const Locale& actualLoc, 160 const char* expReqValid="gt", 161 const char* expValidActual="ge"); 162 163 /** 164 * routine to perform subtests, used by TestDisplayNames 165 **/ 166 void doTestDisplayNames(Locale& inLocale, int32_t compareIndex); 167 /** 168 * additional intialization for datatables storing expected values 169 **/ 170 void setUpDataTable(void); 171 172 UnicodeString** dataTable; 173 174 enum { 175 ENGLISH = 0, 176 FRENCH = 1, 177 CROATIAN = 2, 178 GREEK = 3, 179 NORWEGIAN = 4, 180 ITALIAN = 5, 181 XX = 6, 182 CHINESE = 7, 183 MAX_LOCALES = 7 184 }; 185 186 enum { 187 LANG = 0, 188 SCRIPT, 189 CTRY, 190 VAR, 191 NAME, 192 LANG3, 193 CTRY3, 194 LCID, 195 DLANG_EN, 196 DSCRIPT_EN, 197 DCTRY_EN, 198 DVAR_EN, 199 DNAME_EN, 200 DLANG_FR, 201 DSCRIPT_FR, 202 DCTRY_FR, 203 DVAR_FR, 204 DNAME_FR, 205 DLANG_CA, 206 DSCRIPT_CA, 207 DCTRY_CA, 208 DVAR_CA, 209 DNAME_CA, 210 DLANG_EL, 211 DSCRIPT_EL, 212 DCTRY_EL, 213 DVAR_EL, 214 DNAME_EL, 215 DLANG_NO, 216 DSCRIPT_NO, 217 DCTRY_NO, 218 DVAR_NO, 219 DNAME_NO 220 }; 221 222 #if !UCONFIG_NO_COLLATION 223 /** 224 * Check on registered collators. 225 * @param expectExtra if non-null, the locale ID of an 'extra' locale that is registered. 226 */ 227 void checkRegisteredCollators(const char *expectExtra = NULL); 228 #endif 229 }; 230