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

Side by Side Diff: source/test/cintltst/currtest.c

Issue 1621843002: ICU 56 update step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@561
Patch Set: Created 4 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/cintltst/cucdtst.c ('k') | source/test/cintltst/custrtst.c » ('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) 2005-2014, International Business Machines Corporation and 3 * Copyright (c) 2005-2015, International Business Machines Corporation and
4 * others. All Rights Reserved. 4 * others. All Rights Reserved.
5 ********************************************************************/ 5 ********************************************************************/
6 #include "unicode/utypes.h" 6 #include "unicode/utypes.h"
7 7
8 #if !UCONFIG_NO_FORMATTING 8 #if !UCONFIG_NO_FORMATTING
9 #include "unicode/unum.h" 9 #include "unicode/unum.h"
10 #include "unicode/ucurr.h" 10 #include "unicode/ucurr.h"
11 #include "unicode/ustring.h" 11 #include "unicode/ustring.h"
12 #include "cintltst.h" 12 #include "cintltst.h"
13 #include "cstring.h" 13 #include "cstring.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 if (checkItemCount(UCURR_COMMON|UCURR_UNCOMMON) != 0) { 152 if (checkItemCount(UCURR_COMMON|UCURR_UNCOMMON) != 0) {
153 log_err("Error: UCURR_DEPRECATED|UCURR_NON_DEPRECATED should return 0 it ems\n"); 153 log_err("Error: UCURR_DEPRECATED|UCURR_NON_DEPRECATED should return 0 it ems\n");
154 } 154 }
155 } 155 }
156 156
157 static void TestFractionDigitOverride(void) { 157 static void TestFractionDigitOverride(void) {
158 UErrorCode status = U_ZERO_ERROR; 158 UErrorCode status = U_ZERO_ERROR;
159 UNumberFormat *fmt = unum_open(UNUM_CURRENCY, NULL, 0, "hu_HU", NULL, &statu s); 159 UNumberFormat *fmt = unum_open(UNUM_CURRENCY, NULL, 0, "hu_HU", NULL, &statu s);
160 UChar buffer[256]; 160 UChar buffer[256];
161 UChar expectedBuf[256]; 161 UChar expectedBuf[256];
162 const char expectedFirst[] = "123,46\\u00A0HUF"; /* changed to use 2 fractio n digits */ 162 const char expectedFirst[] = "123,46\\u00A0Ft"; /* changed to use 2 fraction digits */
163 const char expectedSecond[] = "123,46\\u00A0HUF"; 163 const char expectedSecond[] = "123,46\\u00A0Ft";
164 const char expectedThird[] = "123,456\\u00A0HUF"; 164 const char expectedThird[] = "123,456\\u00A0Ft";
165 if (U_FAILURE(status)) { 165 if (U_FAILURE(status)) {
166 log_data_err("Error: unum_open returned %s (Are you missing data?)\n", my ErrorName(status)); 166 log_data_err("Error: unum_open returned %s (Are you missing data?)\n", my ErrorName(status));
167 return; 167 return;
168 } 168 }
169 /* Make sure that you can format normal fraction digits. */ 169 /* Make sure that you can format normal fraction digits. */
170 unum_formatDouble(fmt, 123.456, buffer, sizeof(buffer)/sizeof(buffer[0]), NU LL, &status); 170 unum_formatDouble(fmt, 123.456, buffer, sizeof(buffer)/sizeof(buffer[0]), NU LL, &status);
171 u_unescape(expectedFirst, expectedBuf, strlen(expectedFirst)+1); 171 u_unescape(expectedFirst, expectedBuf, strlen(expectedFirst)+1);
172 if (u_strcmp(buffer, expectedBuf) != 0) { 172 if (u_strcmp(buffer, expectedBuf) != 0) {
173 log_err("Error: unum_formatDouble didn't return %s\n", expectedFirst); 173 log_err("Error: unum_formatDouble didn't return %s\n", expectedFirst);
174 } 174 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 {"Usd", 840}, /* mixed casing */ 237 {"Usd", 840}, /* mixed casing */
238 {"EUR", 978}, 238 {"EUR", 978},
239 {"JPY", 392}, 239 {"JPY", 392},
240 {"XFU", 0}, /* XFU: no numeric code */ 240 {"XFU", 0}, /* XFU: no numeric code */
241 {"ZZZ", 0}, /* ZZZ: undefined ISO currency code */ 241 {"ZZZ", 0}, /* ZZZ: undefined ISO currency code */
242 {"bogus", 0}, /* bogus code */ 242 {"bogus", 0}, /* bogus code */
243 {0, 0}, 243 {0, 0},
244 }; 244 };
245 245
246 static void TestNumericCode(void) { 246 static void TestNumericCode(void) {
247 UChar code[4]; 247 UChar code[8]; // at least one longer than the longest alphaCode
248 int32_t i; 248 int32_t i;
249 int32_t numCode; 249 int32_t numCode;
250 250
251 for (i = 0; NUMCODE_TESTDATA[i].alphaCode; i++) { 251 for (i = 0; NUMCODE_TESTDATA[i].alphaCode; i++) {
252 u_charsToUChars(NUMCODE_TESTDATA[i].alphaCode, code, sizeof(code)/sizeof (code[0])); 252 int32_t length = uprv_strlen(NUMCODE_TESTDATA[i].alphaCode);
253 u_charsToUChars(NUMCODE_TESTDATA[i].alphaCode, code, length + 1); // +1 includes the NUL
253 numCode = ucurr_getNumericCode(code); 254 numCode = ucurr_getNumericCode(code);
254 if (numCode != NUMCODE_TESTDATA[i].numericCode) { 255 if (numCode != NUMCODE_TESTDATA[i].numericCode) {
255 log_data_err("Error: ucurr_getNumericCode returned %d for currency % s, expected - %d\n", 256 log_data_err("Error: ucurr_getNumericCode returned %d for currency % s, expected - %d\n",
256 numCode, NUMCODE_TESTDATA[i].alphaCode, NUMCODE_TESTDATA[i].nume ricCode); 257 numCode, NUMCODE_TESTDATA[i].alphaCode, NUMCODE_TESTDATA[i].nume ricCode);
257 } 258 }
258 } 259 }
259 } 260 }
260 261
261 void addCurrencyTest(TestNode** root); 262 void addCurrencyTest(TestNode** root);
262 263
263 #define TESTCASE(x) addTest(root, &x, "tsformat/currtest/" #x) 264 #define TESTCASE(x) addTest(root, &x, "tsformat/currtest/" #x)
264 265
265 void addCurrencyTest(TestNode** root) 266 void addCurrencyTest(TestNode** root)
266 { 267 {
267 TESTCASE(TestEnumList); 268 TESTCASE(TestEnumList);
268 TESTCASE(TestEnumListReset); 269 TESTCASE(TestEnumListReset);
269 TESTCASE(TestEnumListCount); 270 TESTCASE(TestEnumListCount);
270 TESTCASE(TestFractionDigitOverride); 271 TESTCASE(TestFractionDigitOverride);
271 TESTCASE(TestPrefixSuffix); 272 TESTCASE(TestPrefixSuffix);
272 TESTCASE(TestNumericCode); 273 TESTCASE(TestNumericCode);
273 } 274 }
274 275
275 #endif /* #if !UCONFIG_NO_FORMATTING */ 276 #endif /* #if !UCONFIG_NO_FORMATTING */
OLDNEW
« no previous file with comments | « source/test/cintltst/cucdtst.c ('k') | source/test/cintltst/custrtst.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698