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 TestVariantParsing(void); 74 75 /* Test getting keyword enumeration */ 76 void TestKeywordVariants(void); 77 void TestCreateUnicodeKeywords(void); 78 79 /* Test getting keyword values */ 80 void TestKeywordVariantParsing(void); 81 void TestCreateKeywordSet(void); 82 void TestCreateUnicodeKeywordSet(void); 83 void TestGetKeywordValueStdString(void); 84 void TestGetUnicodeKeywordValueStdString(void); 85 86 /* Test setting keyword values */ 87 void TestSetKeywordValue(void); 88 void TestSetKeywordValueStringPiece(void); 89 void TestSetUnicodeKeywordValueStringPiece(void); 90 91 /* Test getting the locale base name */ 92 void TestGetBaseName(void); 93 94 #if !UCONFIG_NO_FORMATTING 95 void Test4105828(void) ; 96 #endif 97 98 void TestSetIsBogus(void); 99 100 void TestGetLocale(void); 101 102 void TestVariantWithOutCountry(void); 103 104 void TestCanonicalization(void); 105 106 #if !UCONFIG_NO_FORMATTING 107 static UDate date(int32_t y, int32_t m, int32_t d, int32_t hr = 0, int32_t min = 0, int32_t sec = 0); 108 #endif 109 110 void TestCurrencyByDate(void); 111 112 void TestGetVariantWithKeywords(void); 113 void TestIsRightToLeft(); 114 void TestBug11421(); 115 void TestBug13277(); 116 void TestBug13554(); 117 118 void TestAddLikelySubtags(); 119 void TestMinimizeSubtags(); 120 121 void TestForLanguageTag(); 122 void TestToLanguageTag(); 123 124 void TestMoveAssign(); 125 void TestMoveCtor(); 126 127 void TestBug13417VeryLongLanguageTag(); 128 129 private: 130 void _checklocs(const char* label, 131 const char* req, 132 const Locale& validLoc, 133 const Locale& actualLoc, 134 const char* expReqValid="gt", 135 const char* expValidActual="ge"); 136 137 /** 138 * routine to perform subtests, used by TestDisplayNames 139 **/ 140 void doTestDisplayNames(Locale& inLocale, int32_t compareIndex); 141 /** 142 * additional intialization for datatables storing expected values 143 **/ 144 void setUpDataTable(void); 145 146 UnicodeString** dataTable; 147 148 enum { 149 ENGLISH = 0, 150 FRENCH = 1, 151 CROATIAN = 2, 152 GREEK = 3, 153 NORWEGIAN = 4, 154 ITALIAN = 5, 155 XX = 6, 156 CHINESE = 7, 157 MAX_LOCALES = 7 158 }; 159 160 enum { 161 LANG = 0, 162 SCRIPT, 163 CTRY, 164 VAR, 165 NAME, 166 LANG3, 167 CTRY3, 168 LCID, 169 DLANG_EN, 170 DSCRIPT_EN, 171 DCTRY_EN, 172 DVAR_EN, 173 DNAME_EN, 174 DLANG_FR, 175 DSCRIPT_FR, 176 DCTRY_FR, 177 DVAR_FR, 178 DNAME_FR, 179 DLANG_CA, 180 DSCRIPT_CA, 181 DCTRY_CA, 182 DVAR_CA, 183 DNAME_CA, 184 DLANG_EL, 185 DSCRIPT_EL, 186 DCTRY_EL, 187 DVAR_EL, 188 DNAME_EL, 189 DLANG_NO, 190 DSCRIPT_NO, 191 DCTRY_NO, 192 DVAR_NO, 193 DNAME_NO 194 }; 195 196 #if !UCONFIG_NO_COLLATION 197 /** 198 * Check on registered collators. 199 * @param expectExtra if non-null, the locale ID of an 'extra' locale that is registered. 200 */ 201 void checkRegisteredCollators(const char *expectExtra = NULL); 202 #endif 203 }; 204