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