Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(488)

Side by Side Diff: source/test/intltest/loctest.cpp

Issue 845603002: Update ICU to 54.1 step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@master
Patch Set: remove unusued directories Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/test/intltest/loctest.h ('k') | source/test/intltest/measfmttest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /******************************************************************** 1 /********************************************************************
2 * COPYRIGHT: 2 * COPYRIGHT:
3 * Copyright (c) 1997-2013, International Business Machines Corporation and 3 * Copyright (c) 1997-2014, International Business Machines Corporation and
4 * others. All Rights Reserved. 4 * others. All Rights Reserved.
5 ********************************************************************/ 5 ********************************************************************/
6 6
7 #include "loctest.h" 7 #include "loctest.h"
8 #include "unicode/decimfmt.h" 8 #include "unicode/decimfmt.h"
9 #include "unicode/ucurr.h" 9 #include "unicode/ucurr.h"
10 #include "unicode/smpdtfmt.h" 10 #include "unicode/smpdtfmt.h"
11 #include "unicode/dtfmtsym.h" 11 #include "unicode/dtfmtsym.h"
12 #include "unicode/brkiter.h" 12 #include "unicode/brkiter.h"
13 #include "unicode/coll.h" 13 #include "unicode/coll.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 for (int32_t i = 0; i < 33; i++) { 173 for (int32_t i = 0; i < 33; i++) {
174 delete []dataTable[i]; 174 delete []dataTable[i];
175 } 175 }
176 delete []dataTable; 176 delete []dataTable;
177 dataTable = 0; 177 dataTable = 0;
178 } 178 }
179 } 179 }
180 180
181 void LocaleTest::runIndexedTest( int32_t index, UBool exec, const char* &name, c har* /*par*/ ) 181 void LocaleTest::runIndexedTest( int32_t index, UBool exec, const char* &name, c har* /*par*/ )
182 { 182 {
183 switch (index) { 183 TESTCASE_AUTO_BEGIN;
184 TESTCASE(0, TestBasicGetters); 184 TESTCASE_AUTO(TestBasicGetters);
185 TESTCASE(1, TestSimpleResourceInfo); 185 TESTCASE_AUTO(TestSimpleResourceInfo);
186 TESTCASE(2, TestDisplayNames); 186 TESTCASE_AUTO(TestDisplayNames);
187 TESTCASE(3, TestSimpleObjectStuff); 187 TESTCASE_AUTO(TestSimpleObjectStuff);
188 TESTCASE(4, TestPOSIXParsing); 188 TESTCASE_AUTO(TestPOSIXParsing);
189 TESTCASE(5, TestGetAvailableLocales); 189 TESTCASE_AUTO(TestGetAvailableLocales);
190 TESTCASE(6, TestDataDirectory); 190 TESTCASE_AUTO(TestDataDirectory);
191 TESTCASE(7, TestISO3Fallback); 191 TESTCASE_AUTO(TestISO3Fallback);
192 TESTCASE(8, TestGetLangsAndCountries); 192 TESTCASE_AUTO(TestGetLangsAndCountries);
193 TESTCASE(9, TestSimpleDisplayNames); 193 TESTCASE_AUTO(TestSimpleDisplayNames);
194 TESTCASE(10, TestUninstalledISO3Names); 194 TESTCASE_AUTO(TestUninstalledISO3Names);
195 TESTCASE(11, TestAtypicalLocales); 195 TESTCASE_AUTO(TestAtypicalLocales);
196 #if !UCONFIG_NO_FORMATTING 196 #if !UCONFIG_NO_FORMATTING
197 TESTCASE(12, TestThaiCurrencyFormat); 197 TESTCASE_AUTO(TestThaiCurrencyFormat);
198 TESTCASE(13, TestEuroSupport); 198 TESTCASE_AUTO(TestEuroSupport);
199 #endif 199 #endif
200 TESTCASE(14, TestToString); 200 TESTCASE_AUTO(TestToString);
201 #if !UCONFIG_NO_FORMATTING 201 #if !UCONFIG_NO_FORMATTING
202 TESTCASE(15, Test4139940); 202 TESTCASE_AUTO(Test4139940);
203 TESTCASE(16, Test4143951); 203 TESTCASE_AUTO(Test4143951);
204 #endif 204 #endif
205 TESTCASE(17, Test4147315); 205 TESTCASE_AUTO(Test4147315);
206 TESTCASE(18, Test4147317); 206 TESTCASE_AUTO(Test4147317);
207 TESTCASE(19, Test4147552); 207 TESTCASE_AUTO(Test4147552);
208 TESTCASE(20, TestVariantParsing); 208 TESTCASE_AUTO(TestVariantParsing);
209 #if !UCONFIG_NO_FORMATTING 209 #if !UCONFIG_NO_FORMATTING
210 TESTCASE(21, Test4105828); 210 TESTCASE_AUTO(Test4105828);
211 #endif 211 #endif
212 TESTCASE(22, TestSetIsBogus); 212 TESTCASE_AUTO(TestSetIsBogus);
213 TESTCASE(23, TestParallelAPIValues); 213 TESTCASE_AUTO(TestParallelAPIValues);
214 TESTCASE(24, TestKeywordVariants); 214 TESTCASE_AUTO(TestKeywordVariants);
215 TESTCASE(25, TestKeywordVariantParsing); 215 TESTCASE_AUTO(TestKeywordVariantParsing);
216 TESTCASE(26, TestSetKeywordValue); 216 TESTCASE_AUTO(TestSetKeywordValue);
217 TESTCASE(27, TestGetBaseName); 217 TESTCASE_AUTO(TestGetBaseName);
218 #if !UCONFIG_NO_FILE_IO 218 #if !UCONFIG_NO_FILE_IO
219 TESTCASE(28, TestGetLocale); 219 TESTCASE_AUTO(TestGetLocale);
220 #endif 220 #endif
221 TESTCASE(29, TestVariantWithOutCountry); 221 TESTCASE_AUTO(TestVariantWithOutCountry);
222 TESTCASE(30, TestCanonicalization); 222 TESTCASE_AUTO(TestCanonicalization);
223 TESTCASE(31, TestCurrencyByDate); 223 TESTCASE_AUTO(TestCurrencyByDate);
224 » TESTCASE(32, TestGetVariantWithKeywords); 224 TESTCASE_AUTO(TestGetVariantWithKeywords);
225 225 TESTCASE_AUTO(TestIsRightToLeft);
226 // keep the last index in sync with the condition in default: 226 TESTCASE_AUTO_END;
227
228 default:
229 if (index <= 28) { // keep this in sync with the last index!
230 name = "(test omitted by !UCONFIG_NO_FORMATTING)";
231 } else {
232 name = "";
233 }
234 break; //needed to end loop
235 }
236 } 227 }
237 228
238 void LocaleTest::TestBasicGetters() { 229 void LocaleTest::TestBasicGetters() {
239 UnicodeString temp; 230 UnicodeString temp;
240 231
241 int32_t i; 232 int32_t i;
242 for (i = 0; i <= MAX_LOCALES; i++) { 233 for (i = 0; i <= MAX_LOCALES; i++) {
243 Locale testLocale(""); 234 Locale testLocale("");
244 if (rawData[SCRIPT][i] && rawData[SCRIPT][i][0] != 0) { 235 if (rawData[SCRIPT][i] && rawData[SCRIPT][i][0] != 0) {
245 testLocale = Locale(rawData[LANG][i], rawData[SCRIPT][i], rawData[CT RY][i], rawData[VAR][i]); 236 testLocale = Locale(rawData[LANG][i], rawData[SCRIPT][i], rawData[CT RY][i], rawData[VAR][i]);
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 * @bug 4135752 1119 * @bug 4135752
1129 * This would be better tested by the LocaleDataTest. Will move it when I 1120 * This would be better tested by the LocaleDataTest. Will move it when I
1130 * get the LocaleDataTest working again. 1121 * get the LocaleDataTest working again.
1131 */ 1122 */
1132 void 1123 void
1133 LocaleTest::TestThaiCurrencyFormat() 1124 LocaleTest::TestThaiCurrencyFormat()
1134 { 1125 {
1135 UErrorCode status = U_ZERO_ERROR; 1126 UErrorCode status = U_ZERO_ERROR;
1136 DecimalFormat *thaiCurrency = (DecimalFormat*)NumberFormat::createCurrencyIn stance( 1127 DecimalFormat *thaiCurrency = (DecimalFormat*)NumberFormat::createCurrencyIn stance(
1137 Locale("th", "TH"), status); 1128 Locale("th", "TH"), status);
1138 UChar posPrefix = 0x0e3f; 1129 UnicodeString posPrefix("THB", 3, US_INV); // per cldrbug 7618
1139 UnicodeString temp; 1130 UnicodeString temp;
1140 1131
1141 if(U_FAILURE(status) || !thaiCurrency) 1132 if(U_FAILURE(status) || !thaiCurrency)
1142 { 1133 {
1143 dataerrln("Couldn't get th_TH currency -> " + UnicodeString(u_errorName( status))); 1134 dataerrln("Couldn't get th_TH currency -> " + UnicodeString(u_errorName( status)));
1144 return; 1135 return;
1145 } 1136 }
1146 if (thaiCurrency->getPositivePrefix(temp) != UnicodeString(&posPrefix, 1, 1) ) 1137 if (thaiCurrency->getPositivePrefix(temp) != posPrefix)
1147 errln("Thai currency prefix wrong: expected 0x0e3f, got \"" + 1138 errln("Thai currency prefix wrong: expected THB, got \"" +
1148 thaiCurrency->getPositivePrefix(temp) + "\""); 1139 thaiCurrency->getPositivePrefix(temp) + "\"");
1149 if (thaiCurrency->getPositiveSuffix(temp) != "") 1140 if (thaiCurrency->getPositiveSuffix(temp) != "")
1150 errln("Thai currency suffix wrong: expected \"\", got \"" + 1141 errln("Thai currency suffix wrong: expected \"\", got \"" +
1151 thaiCurrency->getPositiveSuffix(temp) + "\""); 1142 thaiCurrency->getPositiveSuffix(temp) + "\"");
1152 1143
1153 delete thaiCurrency; 1144 delete thaiCurrency;
1154 } 1145 }
1155 1146
1156 /** 1147 /**
1157 * @bug 4122371 1148 * @bug 4122371
(...skipping 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after
2539 const char *variant = l.getVariant(); 2530 const char *variant = l.getVariant();
2540 logln(variant); 2531 logln(variant);
2541 test_assert(strcmp("VALLEY", variant) == 0); 2532 test_assert(strcmp("VALLEY", variant) == 0);
2542 2533
2543 UErrorCode status = U_ZERO_ERROR; 2534 UErrorCode status = U_ZERO_ERROR;
2544 char buffer[50]; 2535 char buffer[50];
2545 int32_t len = l.getKeywordValue("foo", buffer, 50, status); 2536 int32_t len = l.getKeywordValue("foo", buffer, 50, status);
2546 buffer[len] = '\0'; 2537 buffer[len] = '\0';
2547 test_assert(strcmp("value", buffer) == 0); 2538 test_assert(strcmp("value", buffer) == 0);
2548 } 2539 }
2540
2541 void LocaleTest::TestIsRightToLeft() {
2542 assertFalse("root LTR", Locale::getRoot().isRightToLeft());
2543 assertFalse("zh LTR", Locale::getChinese().isRightToLeft());
2544 assertTrue("ar RTL", Locale("ar").isRightToLeft());
2545 assertTrue("und-EG RTL", Locale("und-EG").isRightToLeft(), FALSE, TRUE);
2546 assertFalse("fa-Cyrl LTR", Locale("fa-Cyrl").isRightToLeft());
2547 assertTrue("en-Hebr RTL", Locale("en-Hebr").isRightToLeft());
2548 assertTrue("ckb RTL", Locale("ckb").isRightToLeft(), FALSE, TRUE); // Soran i Kurdish
2549 assertFalse("fil LTR", Locale("fil").isRightToLeft());
2550 assertFalse("he-Zyxw LTR", Locale("he-Zyxw").isRightToLeft());
2551 }
OLDNEW
« no previous file with comments | « source/test/intltest/loctest.h ('k') | source/test/intltest/measfmttest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698