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