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

Side by Side Diff: source/test/perf/howExpensiveIs/howExpensiveIs.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
OLDNEW
1 /* 1 /*
2 ********************************************************************** 2 **********************************************************************
3 * Copyright (c) 2011-2012,International Business Machines 3 * Copyright (c) 2011-2014,International Business Machines
4 * Corporation and others. All Rights Reserved. 4 * Corporation and others. All Rights Reserved.
5 ********************************************************************** 5 **********************************************************************
6 */ 6 */
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "sieve.h" 10 #include "sieve.h"
11 #include "unicode/utimer.h" 11 #include "unicode/utimer.h"
12 #include "udbgutil.h" 12 #include "udbgutil.h"
13 #include "unicode/ustring.h" 13 #include "unicode/ustring.h"
14 #include "unicode/decimfmt.h" 14 #include "unicode/decimfmt.h"
15 #include "unicode/udat.h" 15 #include "unicode/udat.h"
16 U_NAMESPACE_USE
16 17
17 #if U_PLATFORM_IMPLEMENTS_POSIX 18 #if U_PLATFORM_IMPLEMENTS_POSIX
18 #include <unistd.h> 19 #include <unistd.h>
19 20
20 static void usage(const char *prog) { 21 static void usage(const char *prog) {
21 fprintf(stderr, "Usage: %s [ -f outfile.xml ] [ -t 'TestName' ]\n", prog); 22 fprintf(stderr, "Usage: %s [ -f outfile.xml ] [ -t 'TestName' ]\n", prog);
22 } 23 }
23 #endif 24 #endif
24 25
25 void runTests(void); 26 void runTests(void);
26 27
27 #ifndef ITERATIONS 28 #ifndef ITERATIONS
28 #define ITERATIONS 5 29 #define ITERATIONS 5
29 #endif 30 #endif
30 31
32 #ifndef TEST_LOCALE
33 #define TEST_LOCALE "en_US"
34 #endif
31 35
32 FILE *out = NULL; 36 FILE *out = NULL;
33 UErrorCode setupStatus = U_ZERO_ERROR; 37 UErrorCode setupStatus = U_ZERO_ERROR;
34 const char *outName = NULL; 38 const char *outName = NULL;
35 int listmode = 0; 39 int listmode = 0;
36 const char *testName = NULL; 40 const char *testName = NULL;
37 const char *progname = NULL; 41 const char *progname = NULL;
38 int errflg = 0; 42 int errflg = 0;
39 int testhit = 0; 43 int testhit = 0;
40 44
(...skipping 14 matching lines...) Expand all
55 #if U_DEBUG 59 #if U_DEBUG
56 { 60 {
57 double m; 61 double m;
58 double s = uprv_getSieveTime(&m); 62 double s = uprv_getSieveTime(&m);
59 fprintf(stderr, "** Standard sieve time: %.9fs +/- %.9fs (%d iterations)\n", s,m, (int)U_LOTS_OF_TIMES); 63 fprintf(stderr, "** Standard sieve time: %.9fs +/- %.9fs (%d iterations)\n", s,m, (int)U_LOTS_OF_TIMES);
60 } 64 }
61 #endif 65 #endif
62 66
63 #if U_PLATFORM_IMPLEMENTS_POSIX 67 #if U_PLATFORM_IMPLEMENTS_POSIX
64 int c; 68 int c;
65 extern int optind; 69 //extern int optind;
66 extern char *optarg; 70 extern char *optarg;
67 while((c=getopt(argc,argv,"lf:t:")) != EOF) { 71 while((c=getopt(argc,argv,"lf:t:")) != EOF) {
68 switch(c) { 72 switch(c) {
69 case 'f': 73 case 'f':
70 outName = optarg; 74 outName = optarg;
71 break; 75 break;
72 case 'l': 76 case 'l':
73 listmode++; 77 listmode++;
74 break; 78 break;
75 case 't': 79 case 't':
(...skipping 30 matching lines...) Expand all
106 return 1; 110 return 1;
107 } else { 111 } else {
108 fprintf(stderr, "# writing results to %s\n", outName); 112 fprintf(stderr, "# writing results to %s\n", outName);
109 } 113 }
110 fprintf(out, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"); 114 fprintf(out, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
111 fprintf(out, "<tests icu=\"%s\">\n", U_ICU_VERSION); 115 fprintf(out, "<tests icu=\"%s\">\n", U_ICU_VERSION);
112 fprintf(out, "<!-- %s -->\n", U_COPYRIGHT_STRING); 116 fprintf(out, "<!-- %s -->\n", U_COPYRIGHT_STRING);
113 } else { 117 } else {
114 fprintf(stderr, "# (no output)\n"); 118 fprintf(stderr, "# (no output)\n");
115 } 119 }
116 120
117 if(listmode && testName!=NULL) { 121 if(listmode && testName!=NULL) {
118 fprintf(stderr, "ERR: no -l mode when specific test with -t\n"); 122 fprintf(stderr, "ERR: no -l mode when specific test with -t\n");
119 usage(progname); 123 usage(progname);
120 return 1; 124 return 1;
121 } 125 }
122 126
123 127
124 runTests(); 128 runTests();
125 129
126 130
127 if(out!=NULL) { 131 if(out!=NULL) {
128 #ifndef SKIP_INFO 132 #ifndef SKIP_INFO
129 udbg_writeIcuInfo(out); 133 udbg_writeIcuInfo(out);
130 #endif 134 #endif
131 fprintf(out, "</tests>\n"); 135 fprintf(out, "</tests>\n");
132 fclose(out); 136 fclose(out);
133 } 137 }
134 138
135 if(U_FAILURE(setupStatus)) { 139 if(U_FAILURE(setupStatus)) {
136 fprintf(stderr, "Error in tests: %s\n", u_errorName(setupStatus)); 140 fprintf(stderr, "Error in tests: %s\n", u_errorName(setupStatus));
137 return 1; 141 return 1;
138 } 142 }
139 143
140 return 0; 144 return 0;
141 } 145 }
142 146
143 class HowExpensiveTest { 147 class HowExpensiveTest {
144 public: 148 public:
145 virtual ~HowExpensiveTest(){} 149 virtual ~HowExpensiveTest(){}
146 protected: 150 protected:
147 HowExpensiveTest(const char *name, const char *file, int32_t line) : fName(nam e), fFile(file), fLine(line) {} 151 HowExpensiveTest(const char *name, const char *file, int32_t line) : fName(nam e), fFile(file), fLine(line) {}
148 protected: 152 protected:
149 /** 153 /**
150 * @return number of iterations 154 * @return number of iterations
151 */ 155 */
152 virtual int32_t run() = 0; 156 virtual int32_t run() = 0;
153 virtual void warmup() { run(); } 157 virtual void warmup() { run(); }
154 public: 158 public:
155 virtual const char *getName() { return fName; } 159 virtual const char *getName() { return fName; }
156 public: 160 public:
157 virtual int32_t runTest(double *subTime) { 161 virtual int32_t runTest(double *subTime) {
158 UTimer a,b; 162 UTimer a,b;
159 utimer_getTime(&a); 163 utimer_getTime(&a);
160 int32_t iter = run(); 164 int32_t iter = run();
161 utimer_getTime(&b); 165 utimer_getTime(&b);
162 *subTime = utimer_getDeltaSeconds(&a,&b); 166 *subTime = utimer_getDeltaSeconds(&a,&b);
163 return iter; 167 return iter;
(...skipping 29 matching lines...) Expand all
193 fprintf(stderr, "%s:%d:\t%s\n", t.fFile, t.fLine, t.getName()); 197 fprintf(stderr, "%s:%d:\t%s\n", t.fFile, t.fLine, t.getName());
194 testhit++; 198 testhit++;
195 return; 199 return;
196 } else { 200 } else {
197 fprintf(stderr, "%s:%d: Running: %s\n", t.fFile, t.fLine, t.getName()); 201 fprintf(stderr, "%s:%d: Running: %s\n", t.fFile, t.fLine, t.getName());
198 testhit++; 202 testhit++;
199 } 203 }
200 double sieveTime = uprv_getSieveTime(NULL); 204 double sieveTime = uprv_getSieveTime(NULL);
201 double st; 205 double st;
202 double me; 206 double me;
203 207
204 fflush(stdout); 208 fflush(stdout);
205 fflush(stderr); 209 fflush(stderr);
206 int32_t iter = t.runTests(&st,&me); 210 int32_t iter = t.runTests(&st,&me);
207 if(U_FAILURE(setupStatus)) { 211 if(U_FAILURE(setupStatus)) {
208 fprintf(stderr, "Error in tests: %s\n", u_errorName(setupStatus)); 212 fprintf(stderr, "Error in tests: %s\n", u_errorName(setupStatus));
209 return; 213 return;
210 } 214 }
211 fflush(stdout); 215 fflush(stdout);
212 fflush(stderr); 216 fflush(stderr);
213 217
214 double stn = st/sieveTime; 218 double stn = st/sieveTime;
215 219
216 printf("%s\t%.9f\t%.9f +/- %.9f, @ %d iter\n", t.getName(),stn,st,me,iter); 220 printf("%s\t%.9f\t%.9f +/- %.9f, @ %d iter\n", t.getName(),stn,st,me,iter);
217 221
218 if(out!=NULL) { 222 if(out!=NULL) {
219 fprintf(out, " <test name=\"%s\" standardizedTime=\"%f\" realDuration=\"%f \" marginOfError=\"%f\" iterations=\"%d\" />\n", 223 fprintf(out, " <test name=\"%s\" standardizedTime=\"%f\" realDuration=\"%f \" marginOfError=\"%f\" iterations=\"%d\" />\n",
220 tn,stn,st,me,iter); 224 tn,stn,st,me,iter);
221 fflush(out); 225 fflush(out);
222 } 226 }
223 } 227 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 char name[100]; 269 char name[100];
266 public: 270 public:
267 virtual const char *getName() { 271 virtual const char *getName() {
268 if(name[0]==0) { 272 if(name[0]==0) {
269 sprintf(name,"%s:p=|%s|,str=|%s|",getClassName(),fCPat,fCStr); 273 sprintf(name,"%s:p=|%s|,str=|%s|",getClassName(),fCPat,fCStr);
270 } 274 }
271 return name; 275 return name;
272 } 276 }
273 protected: 277 protected:
274 virtual UNumberFormat* initFmt() { 278 virtual UNumberFormat* initFmt() {
275 return unum_open(UNUM_PATTERN_DECIMAL, fPat.getTerminatedBuffer(), -1, "en_U S", 0, &setupStatus); 279 return unum_open(UNUM_PATTERN_DECIMAL, fPat.getTerminatedBuffer(), -1, TEST_ LOCALE, 0, &setupStatus);
276 } 280 }
277 virtual const char *getClassName() { 281 virtual const char *getClassName() {
278 return "NumTest"; 282 return "NumTest";
279 } 283 }
280 public: 284 public:
281 NumTest(const char *pat, const char *num, double expect, const char *FILE, int LINE) 285 NumTest(const char *pat, const char *num, double expect, const char *FILE, int LINE)
282 : HowExpensiveTest("(n/a)",FILE, LINE), 286 : HowExpensiveTest("(n/a)",FILE, LINE),
283 fExpect(expect), 287 fExpect(expect),
284 fFmt(0), 288 fFmt(0),
285 fPat(pat, -1, US_INV), 289 fPat(pat, -1, US_INV),
286 fString(num,-1,US_INV), 290 fString(num,-1,US_INV),
287 fStr(fString.getTerminatedBuffer()), 291 fStr(fString.getTerminatedBuffer()),
288 fLen(u_strlen(fStr)), 292 fLen(u_strlen(fStr)),
289 fFile(FILE), 293 fFile(FILE),
290 fLine(LINE), 294 fLine(LINE),
291 fCPat(pat), 295 fCPat(pat),
292 fCStr(num) 296 fCStr(num)
293 { 297 {
294 name[0]=0; 298 name[0]=0;
295 } 299 }
296 void warmup() { 300 void warmup() {
297 fFmt = initFmt(); 301 fFmt = initFmt();
298 if(U_SUCCESS(setupStatus)) { 302 if(U_SUCCESS(setupStatus)) {
299 double trial = unum_parseDouble(fFmt,fStr,fLen, NULL, &setupStatus); 303 double trial = unum_parseDouble(fFmt,fStr,fLen, NULL, &setupStatus);
300 if(U_SUCCESS(setupStatus) && trial!=fExpect) { 304 if(U_SUCCESS(setupStatus) && trial!=fExpect) {
301 setupStatus = U_INTERNAL_PROGRAM_ERROR; 305 setupStatus = U_INTERNAL_PROGRAM_ERROR;
302 printf("%s:%d: warmup() %s got %.8f expected %.8f\n", 306 printf("%s:%d: warmup() %s got %.8f expected %.8f\n",
303 fFile,fLine,getName(),trial,fExpect); 307 fFile,fLine,getName(),trial,fExpect);
304 } 308 }
305 } 309 }
306 } 310 }
307 int32_t run() { 311 int32_t run() {
308 double trial=0.0; 312 double trial=0.0;
309 int i; 313 int i;
310 for(i=0;i<U_LOTS_OF_TIMES;i++){ 314 for(i=0;i<U_LOTS_OF_TIMES;i++){
311 trial = unum_parse(fFmt,fStr,fLen, NULL, &setupStatus); 315 trial = unum_parse(fFmt,fStr,fLen, NULL, &setupStatus);
312 } 316 }
313 return i; 317 return i;
314 } 318 }
315 virtual ~NumTest(){} 319 virtual ~NumTest(){}
316 }; 320 };
317 321
318 #define DO_NumTest(p,n,x) { NumTest t(p,n,x,__FILE__,__LINE__); runTestOn(t); } 322 #define DO_NumTest(p,n,x) { NumTest t(p,n,x,__FILE__,__LINE__); runTestOn(t); }
319 323
320 324
321 class AttrNumTest : public NumTest 325 class AttrNumTest : public NumTest
322 { 326 {
323 private: 327 private:
324 UNumberFormatAttribute fAttr; 328 UNumberFormatAttribute fAttr;
325 int32_t fAttrValue; 329 int32_t fAttrValue;
326 char name2[100]; 330 char name2[100];
327 protected: 331 protected:
328 virtual const char *getClassName() { 332 virtual const char *getClassName() {
329 sprintf(name2,"AttrNumTest:%d=%d", fAttr,fAttrValue); 333 sprintf(name2,"AttrNumTest:%d=%d", fAttr,fAttrValue);
330 return name2; 334 return name2;
331 } 335 }
332 public: 336 public:
333 AttrNumTest(const char *pat, const char *num, double expect, const char *FILE, int LINE, UNumberFormatAttribute attr, int32_t newValue) 337 AttrNumTest(const char *pat, const char *num, double expect, const char *FILE, int LINE, UNumberFormatAttribute attr, int32_t newValue)
334 : NumTest(pat,num,expect,FILE,LINE), 338 : NumTest(pat,num,expect,FILE,LINE),
335 fAttr(attr), 339 fAttr(attr),
336 fAttrValue(newValue) 340 fAttrValue(newValue)
337 { 341 {
338 } 342 }
339 virtual UNumberFormat* initFmt() { 343 virtual UNumberFormat* initFmt() {
340 UNumberFormat *fmt = NumTest::initFmt(); 344 UNumberFormat *fmt = NumTest::initFmt();
341 unum_setAttribute(fmt, fAttr,fAttrValue); 345 unum_setAttribute(fmt, fAttr,fAttrValue);
342 return fmt; 346 return fmt;
343 } 347 }
344 }; 348 };
345 349
346 #define DO_AttrNumTest(p,n,x,a,v) { AttrNumTest t(p,n,x,__FILE__,__LINE__,a,v); runTestOn(t); } 350 #define DO_AttrNumTest(p,n,x,a,v) { AttrNumTest t(p,n,x,__FILE__,__LINE__,a,v); runTestOn(t); }
347 351
348 352
349 class NOXNumTest : public NumTest 353 class NOXNumTest : public NumTest
350 { 354 {
351 private: 355 private:
352 UNumberFormatAttribute fAttr; 356 UNumberFormatAttribute fAttr;
353 int32_t fAttrValue; 357 int32_t fAttrValue;
354 char name2[100]; 358 char name2[100];
355 protected: 359 protected:
356 virtual const char *getClassName() { 360 virtual const char *getClassName() {
357 sprintf(name2,"NOXNumTest:%d=%d", fAttr,fAttrValue); 361 sprintf(name2,"NOXNumTest:%d=%d", fAttr,fAttrValue);
358 return name2; 362 return name2;
359 } 363 }
360 public: 364 public:
361 NOXNumTest(const char *pat, const char *num, double expect, const char *FILE, int LINE /*, UNumberFormatAttribute attr, int32_t newValue */) 365 NOXNumTest(const char *pat, const char *num, double expect, const char *FILE, int LINE /*, UNumberFormatAttribute attr, int32_t newValue */)
362 : NumTest(pat,num,expect,FILE,LINE) /* , 366 : NumTest(pat,num,expect,FILE,LINE) /* ,
363 fAttr(attr), 367 fAttr(attr),
364 fAttrValue(newValue) */ 368 fAttrValue(newValue) */
365 { 369 {
366 } 370 }
367 virtual UNumberFormat* initFmt() { 371 virtual UNumberFormat* initFmt() {
368 UNumberFormat *fmt = NumTest::initFmt(); 372 UNumberFormat *fmt = NumTest::initFmt();
369 //unum_setAttribute(fmt, fAttr,fAttrValue); 373 //unum_setAttribute(fmt, fAttr,fAttrValue);
370 return fmt; 374 return fmt;
371 } 375 }
(...skipping 21 matching lines...) Expand all
393 char name[100]; 397 char name[100];
394 public: 398 public:
395 virtual const char *getName() { 399 virtual const char *getName() {
396 if(name[0]==0) { 400 if(name[0]==0) {
397 sprintf(name,"%s:p=|%s|,str=|%s|",getClassName(),fCPat,fCStr); 401 sprintf(name,"%s:p=|%s|,str=|%s|",getClassName(),fCPat,fCStr);
398 } 402 }
399 return name; 403 return name;
400 } 404 }
401 protected: 405 protected:
402 virtual UNumberFormat* initFmt() { 406 virtual UNumberFormat* initFmt() {
403 return unum_open(UNUM_PATTERN_DECIMAL, fPat.getTerminatedBuffer(), -1, "en_U S", 0, &setupStatus); 407 return unum_open(UNUM_PATTERN_DECIMAL, fPat.getTerminatedBuffer(), -1, TEST_ LOCALE, 0, &setupStatus);
404 } 408 }
405 virtual const char *getClassName() { 409 virtual const char *getClassName() {
406 return "NumFmtTest"; 410 return "NumFmtTest";
407 } 411 }
408 public: 412 public:
409 NumFmtTest(const char *pat, const char *num, double expect, const char *FILE, int LINE) 413 NumFmtTest(const char *pat, const char *num, double expect, const char *FILE, int LINE)
410 : HowExpensiveTest("(n/a)",FILE, LINE), 414 : HowExpensiveTest("(n/a)",FILE, LINE),
411 fExpect(expect), 415 fExpect(expect),
412 fFmt(0), 416 fFmt(0),
413 fPat(pat, -1, US_INV), 417 fPat(pat, -1, US_INV),
414 fString(num,-1,US_INV), 418 fString(num,-1,US_INV),
415 fStr(fString.getTerminatedBuffer()), 419 fStr(fString.getTerminatedBuffer()),
416 fLen(u_strlen(fStr)), 420 fLen(u_strlen(fStr)),
417 fFile(FILE), 421 fFile(FILE),
418 fLine(LINE), 422 fLine(LINE),
419 fCPat(pat), 423 fCPat(pat),
420 fCStr(num) 424 fCStr(num)
421 { 425 {
422 name[0]=0; 426 name[0]=0;
423 } 427 }
424 void warmup() { 428 void warmup() {
425 fFmt = initFmt(); 429 fFmt = initFmt();
426 UChar buf[100]; 430 UChar buf[100];
427 if(U_SUCCESS(setupStatus)) { 431 if(U_SUCCESS(setupStatus)) {
428 int32_t trial = unum_formatDouble(fFmt,fExpect, buf, 100, NULL, &setupStat us); 432 int32_t trial = unum_formatDouble(fFmt,fExpect, buf, 100, NULL, &setupStat us);
429 if(!U_SUCCESS(setupStatus) 433 if(!U_SUCCESS(setupStatus)
430 || trial!=fLen 434 || trial!=fLen
431 ||trial<=0 435 ||trial<=0
432 || u_strncmp(fStr,buf,trial) ) { 436 || u_strncmp(fStr,buf,trial) ) {
433 char strBuf[200]; 437 char strBuf[200];
434 u_strToUTF8(strBuf,200,NULL,buf,trial+1,&setupStatus); 438 u_strToUTF8(strBuf,200,NULL,buf,trial+1,&setupStatus);
435 printf("%s:%d: warmup() %s got %s expected %s, err %s\n", 439 printf("%s:%d: warmup() %s got %s expected %s, err %s\n",
436 fFile,fLine,getName(),strBuf,fCStr, u_errorName(setupStatus)); 440 fFile,fLine,getName(),strBuf,fCStr, u_errorName(setupStatus));
437 setupStatus = U_INTERNAL_PROGRAM_ERROR; 441 setupStatus = U_INTERNAL_PROGRAM_ERROR;
438 } 442 }
439 } 443 }
440 } 444 }
441 int32_t run() { 445 int32_t run() {
442 int32_t trial; 446 int32_t trial;
443 int i; 447 int i;
444 UChar buf[100]; 448 UChar buf[100];
445 if(U_SUCCESS(setupStatus)) { 449 if(U_SUCCESS(setupStatus)) {
446 for(i=0;i<U_LOTS_OF_TIMES;i++){ 450 for(i=0;i<U_LOTS_OF_TIMES;i++){
447 trial = unum_formatDouble(fFmt,fExpect, buf, 100, NULL, &setupStatus); 451 trial = unum_formatDouble(fFmt,fExpect, buf, 100, NULL, &setupStatus);
448 } 452 }
449 } 453 }
450 return i; 454 return i;
451 } 455 }
452 virtual ~NumFmtTest(){} 456 virtual ~NumFmtTest(){}
453 }; 457 };
454 458
455 #define DO_NumFmtTest(p,n,x) { NumFmtTest t(p,n,x,__FILE__,__LINE__); runTestOn( t); } 459 #define DO_NumFmtTest(p,n,x) { NumFmtTest t(p,n,x,__FILE__,__LINE__); runTestOn( t); }
456 460
457
458 class NumFmtInt64Test : public HowExpensiveTest { 461 class NumFmtInt64Test : public HowExpensiveTest {
462 public:
463 enum EMode {
464 kDefault,
465 kPattern,
466 kApplyPattern,
467 kGroupOff,
468 kApplyGroupOff
469 };
459 private: 470 private:
471 EMode fMode;
460 int64_t fExpect; 472 int64_t fExpect;
461 UNumberFormat *fFmt; 473 UNumberFormat *fFmt;
462 UnicodeString fPat; 474 UnicodeString fPat;
463 UnicodeString fString; 475 UnicodeString fString;
464 const UChar *fStr; 476 const UChar *fStr;
465 int32_t fLen; 477 int32_t fLen;
466 const char *fFile; 478 const char *fFile;
467 int fLine; 479 int fLine;
468 const char *fCPat; 480 const char *fCPat;
469 const char *fCStr; 481 const char *fCStr;
470 char name[100]; 482 char name[100];
471 public: 483 public:
472 virtual const char *getName() { 484 virtual const char *getName() {
473 if(name[0]==0) { 485 if(name[0]==0) {
474 sprintf(name,"%s:p=|%s|,str=|%s|",getClassName(),fCPat,fCStr); 486 sprintf(name,"%s:p=|%s|,str=|%s|",getClassName(),fCPat,fCStr);
475 } 487 }
476 return name; 488 return name;
477 } 489 }
478 protected: 490 protected:
479 virtual UNumberFormat* initFmt() { 491 virtual UNumberFormat* initFmt() {
480 return unum_open(UNUM_PATTERN_DECIMAL, fPat.getTerminatedBuffer(), -1, "en_U S", 0, &setupStatus); 492 switch(fMode) {
493 case kPattern:
494 return unum_open(UNUM_PATTERN_DECIMAL, fPat.getTerminatedBuffer(), -1, TES T_LOCALE, 0, &setupStatus);
495 case kApplyPattern:
496 {
497 UNumberFormat *fmt = unum_open(UNUM_DECIMAL, NULL, -1, TEST_LOCALE, 0, & setupStatus);
498 unum_applyPattern(fmt, FALSE, fPat.getTerminatedBuffer(), -1, NULL, &set upStatus);
499 return fmt;
500 }
501 case kGroupOff:
502 {
503 UNumberFormat *fmt = unum_open(UNUM_PATTERN_DECIMAL, fPat.getTerminatedB uffer(), -1, TEST_LOCALE, 0, &setupStatus);
504 unum_setAttribute(fmt, UNUM_GROUPING_USED, UNUM_NO);
505 return fmt;
506 }
507 case kApplyGroupOff:
508 {
509 UNumberFormat *fmt = unum_open(UNUM_DECIMAL, NULL, -1, TEST_LOCALE, 0, & setupStatus);
510 unum_applyPattern(fmt, FALSE, fPat.getTerminatedBuffer(), -1, NULL, &set upStatus);
511 unum_setAttribute(fmt, UNUM_GROUPING_USED, UNUM_NO);
512 return fmt;
513 }
514 default:
515 case kDefault:
516 return unum_open(UNUM_DEFAULT, NULL, -1, TEST_LOCALE, 0, &setupStatus);
517 }
481 } 518 }
482 virtual const char *getClassName() { 519 virtual const char *getClassName() {
483 return "NumFmtInt64Test"; 520 switch(fMode) {
521 case EMode::kDefault:
522 return "NumFmtInt64Test (default)";
523 case EMode::kPattern:
524 return "NumFmtInt64Test (pattern)";
525 case EMode::kApplyPattern:
526 return "NumFmtInt64Test (applypattern)";
527 case EMode::kGroupOff:
528 return "NumFmtInt64Test (pattern, group=off)";
529 case EMode::kApplyGroupOff:
530 return "NumFmtInt64Test (applypattern, group=off)";
531 default:
532 return "NumFmtInt64Test (? ? ?)";
533 }
484 } 534 }
485 public: 535 public:
486 NumFmtInt64Test(const char *pat, const char *num, int64_t expect, const char * FILE, int LINE) 536 NumFmtInt64Test(const char *pat, const char *num, int64_t expect, const char * FILE, int LINE, EMode mode)
487 : HowExpensiveTest("(n/a)",FILE, LINE), 537 : HowExpensiveTest("(n/a)",FILE, LINE),
538 fMode(mode),
488 fExpect(expect), 539 fExpect(expect),
489 fFmt(0), 540 fFmt(0),
490 fPat(pat, -1, US_INV), 541 fPat(pat, -1, US_INV),
491 fString(num,-1,US_INV), 542 fString(num,-1,US_INV),
492 fStr(fString.getTerminatedBuffer()), 543 fStr(fString.getTerminatedBuffer()),
493 fLen(u_strlen(fStr)), 544 fLen(u_strlen(fStr)),
494 fFile(FILE), 545 fFile(FILE),
495 fLine(LINE), 546 fLine(LINE),
496 fCPat(pat), 547 fCPat(pat),
497 fCStr(num) 548 fCStr(num)
498 { 549 {
499 name[0]=0; 550 name[0]=0;
500 } 551 }
501 void warmup() { 552 void warmup() {
502 fFmt = initFmt(); 553 fFmt = initFmt();
503 UChar buf[100]; 554 UChar buf[100];
504 if(U_SUCCESS(setupStatus)) { 555 if(U_SUCCESS(setupStatus)) {
505 int32_t trial = unum_formatInt64(fFmt,fExpect, buf, 100, NULL, &setupStatu s); 556 int32_t trial = unum_formatInt64(fFmt,fExpect, buf, 100, NULL, &setupStatu s);
506 if(!U_SUCCESS(setupStatus) 557 if(!U_SUCCESS(setupStatus)
507 || trial!=fLen 558 || trial!=fLen
508 ||trial<=0 559 ||trial<=0
509 || u_strncmp(fStr,buf,trial) ) { 560 || u_strncmp(fStr,buf,trial) ) {
510 char strBuf[200]; 561 char strBuf[200];
511 u_strToUTF8(strBuf,200,NULL,buf,trial+1,&setupStatus); 562 u_strToUTF8(strBuf,200,NULL,buf,trial+1,&setupStatus);
512 printf("%s:%d: warmup() %s got %s (len %d) expected %s (len %d), err %s\ n", 563 printf("%s:%d: warmup() %s got %s (len %d) expected %s (len %d), err %s\ n",
513 fFile,fLine,getName(),strBuf,trial,fCStr,fLen, u_errorName(setupS tatus)); 564 fFile,fLine,getName(),strBuf,trial,fCStr,fLen, u_errorName(setupS tatus));
514 setupStatus = U_INTERNAL_PROGRAM_ERROR; 565 setupStatus = U_INTERNAL_PROGRAM_ERROR;
515 } 566 }
516 } 567 }
517 } 568 }
518 int32_t run() { 569 int32_t run() {
519 int32_t trial; 570 int32_t trial;
520 int i; 571 int i;
521 UChar buf[100]; 572 UChar buf[100];
522 if(U_SUCCESS(setupStatus)) { 573 if(U_SUCCESS(setupStatus)) {
523 for(i=0;i<U_LOTS_OF_TIMES;i++){ 574 for(i=0;i<U_LOTS_OF_TIMES;i++){
524 trial = unum_formatInt64(fFmt,fExpect, buf, 100, NULL, &setupStatus); 575 trial = unum_formatInt64(fFmt,fExpect, buf, 100, NULL, &setupStatus);
525 } 576 }
526 } 577 }
527 return i; 578 return i;
528 } 579 }
529 virtual ~NumFmtInt64Test(){} 580 virtual ~NumFmtInt64Test(){}
530 }; 581 };
531 582
532 #define DO_NumFmtInt64Test(p,n,x) { NumFmtInt64Test t(p,n,x,__FILE__,__LINE__); runTestOn(t); } 583 /**
584 * unum_open .. with pattern, == new DecimalFormat(pattern)
585 */
586 #define DO_NumFmtInt64Test(p,n,x) { NumFmtInt64Test t(p,n,x,__FILE__,__LINE__,Nu mFmtInt64Test::EMode::kPattern); runTestOn(t); }
587 /**
588 * unum_open(UNUM_DECIMAL), then
589 */
590 #define DO_NumFmtInt64Test_apply(p,n,x) { NumFmtInt64Test t(p,n,x,__FILE__,__LIN E__,NumFmtInt64Test::EMode::kApplyPattern); runTestOn(t); }
591
592 #define DO_NumFmtInt64Test_default(p,n,x) { NumFmtInt64Test t(p,n,x,__FILE__,__L INE__,NumFmtInt64Test::EMode::kDefault); runTestOn(t); }
593 #define DO_NumFmtInt64Test_gr0(p,n,x) { NumFmtInt64Test t(p,n,x,__FILE__,__LINE_ _,NumFmtInt64Test::EMode::kGroupOff); runTestOn(t); }
594 #define DO_NumFmtInt64Test_applygr0(p,n,x) { NumFmtInt64Test t(p,n,x,__FILE__,__ LINE__,NumFmtInt64Test::EMode::kApplyGroupOff); runTestOn(t); }
533 595
534 596
535 class NumFmtStringPieceTest : public HowExpensiveTest { 597 class NumFmtStringPieceTest : public HowExpensiveTest {
536 private: 598 private:
537 const StringPiece &fExpect; 599 const StringPiece &fExpect;
538 UNumberFormat *fFmt; 600 UNumberFormat *fFmt;
539 UnicodeString fPat; 601 UnicodeString fPat;
540 UnicodeString fString; 602 UnicodeString fString;
541 const UChar *fStr; 603 const UChar *fStr;
542 int32_t fLen; 604 int32_t fLen;
(...skipping 13 matching lines...) Expand all
556 virtual UNumberFormat* initFmt() { 618 virtual UNumberFormat* initFmt() {
557 DecimalFormat *d = new DecimalFormat(setupStatus); 619 DecimalFormat *d = new DecimalFormat(setupStatus);
558 UParseError pe; 620 UParseError pe;
559 d->applyPattern(fPat, pe, setupStatus); 621 d->applyPattern(fPat, pe, setupStatus);
560 return (UNumberFormat*) d; 622 return (UNumberFormat*) d;
561 } 623 }
562 virtual const char *getClassName() { 624 virtual const char *getClassName() {
563 return "NumFmtStringPieceTest"; 625 return "NumFmtStringPieceTest";
564 } 626 }
565 public: 627 public:
566 NumFmtStringPieceTest(const char *pat, const char *num, const StringPiece& exp ect, const char *FILE, int LINE) 628 NumFmtStringPieceTest(const char *pat, const char *num, const StringPiece& exp ect, const char *FILE, int LINE)
567 : HowExpensiveTest("(n/a)",FILE, LINE), 629 : HowExpensiveTest("(n/a)",FILE, LINE),
568 fExpect(expect), 630 fExpect(expect),
569 fFmt(0), 631 fFmt(0),
570 fPat(pat, -1, US_INV), 632 fPat(pat, -1, US_INV),
571 fString(num,-1,US_INV), 633 fString(num,-1,US_INV),
572 fStr(fString.getTerminatedBuffer()), 634 fStr(fString.getTerminatedBuffer()),
573 fLen(u_strlen(fStr)), 635 fLen(u_strlen(fStr)),
574 fFile(FILE), 636 fFile(FILE),
575 fLine(LINE), 637 fLine(LINE),
576 fCPat(pat), 638 fCPat(pat),
577 fCStr(num) 639 fCStr(num)
578 { 640 {
579 name[0]=0; 641 name[0]=0;
580 } 642 }
581 void warmup() { 643 void warmup() {
582 fFmt = initFmt(); 644 fFmt = initFmt();
583 UnicodeString buf; 645 UnicodeString buf;
584 if(U_SUCCESS(setupStatus)) { 646 if(U_SUCCESS(setupStatus)) {
585 buf.remove(); 647 buf.remove();
586 ((const DecimalFormat*)fFmt)->format(fExpect, buf, NULL, setupStatus); 648 ((const DecimalFormat*)fFmt)->format(fExpect, buf, NULL, setupStatus);
587 if(!U_SUCCESS(setupStatus) 649 if(!U_SUCCESS(setupStatus)
588 || fString!=buf 650 || fString!=buf
589 ) { 651 ) {
590 char strBuf[200]; 652 char strBuf[200];
591 u_strToUTF8(strBuf,200,NULL,buf.getTerminatedBuffer(),buf.length()+1,&se tupStatus); 653 u_strToUTF8(strBuf,200,NULL,buf.getTerminatedBuffer(),buf.length()+1,&se tupStatus);
592 printf("%s:%d: warmup() %s got %s (len %d) expected %s (len %d), err %s\ n", 654 printf("%s:%d: warmup() %s got %s (len %d) expected %s (len %d), err %s\ n",
593 fFile,fLine,getName(),strBuf,buf.length(),fCStr,fLen, u_errorName (setupStatus)); 655 fFile,fLine,getName(),strBuf,buf.length(),fCStr,fLen, u_errorName (setupStatus));
594 setupStatus = U_INTERNAL_PROGRAM_ERROR; 656 setupStatus = U_INTERNAL_PROGRAM_ERROR;
595 } 657 }
596 } 658 }
597 } 659 }
598 660
599 int32_t run() { 661 int32_t run() {
662 #if U_DEBUG
600 int32_t trial; 663 int32_t trial;
664 #endif
601 int i=0; 665 int i=0;
602 UnicodeString buf; 666 UnicodeString buf;
603 if(U_SUCCESS(setupStatus)) { 667 if(U_SUCCESS(setupStatus)) {
604 for(i=0;i<U_LOTS_OF_TIMES;i++){ 668 for(i=0;i<U_LOTS_OF_TIMES;i++){
605 buf.remove(); 669 buf.remove();
606 ((const DecimalFormat*)fFmt)->format(fExpect, buf, NULL, setupStatus); 670 ((const DecimalFormat*)fFmt)->format(fExpect, buf, NULL, setupStatus);
607 } 671 }
608 } 672 }
609 return i; 673 return i;
610 } 674 }
611 virtual ~NumFmtStringPieceTest(){} 675 virtual ~NumFmtStringPieceTest(){}
612 }; 676 };
613 677
614 #define DO_NumFmtStringPieceTest(p,n,x) { NumFmtStringPieceTest t(p,n,x,__FILE__ ,__LINE__); runTestOn(t); } 678 #define DO_NumFmtStringPieceTest(p,n,x) { NumFmtStringPieceTest t(p,n,x,__FILE__ ,__LINE__); runTestOn(t); }
615 679
616 // TODO: move, scope. 680 // TODO: move, scope.
617 static UChar pattern[] = { 0x23 }; // '#' 681 static UChar pattern[] = { 0x23 }; // '#'
618 static UChar strdot[] = { '2', '.', '0', 0 }; 682 static UChar strdot[] = { '2', '.', '0', 0 };
619 static UChar strspc[] = { '2', ' ', 0 }; 683 static UChar strspc[] = { '2', ' ', 0 };
620 static UChar strgrp[] = {'2',',','2','2','2', 0 }; 684 static UChar strgrp[] = {'2',',','2','2','2', 0 };
621 static UChar strbeng[] = {0x09E8,0x09E8,0x09E8,0x09E8, 0 }; 685 static UChar strbeng[] = {0x09E8,0x09E8,0x09E8,0x09E8, 0 };
622 686
623 UNumberFormat *NumParseTest_fmt; 687 UNumberFormat *NumParseTest_fmt;
624 688
625 // TODO: de-uglify. 689 // TODO: de-uglify.
626 QuickTest(NumParseTest,{ static UChar pattern[] = { 0x23 }; NumParseTest_f mt = unum_open(UNUM_PATTERN_DECIMAL, pattern, 1, "en_US", 0, &setupStatus); },{ int32_t i; static UChar str[] = { 0x31 };double val; for(i=0;i<U_L OTS_OF_TIMES;i++) { val=unum_parse(NumParseTest_fmt,str,1,NULL,&setupStatus ); } return i; },{unum_close(NumParseTest_fmt);}) 690 QuickTest(NumParseTest,{ static UChar pattern[] = { 0x23 }; NumParseTest_f mt = unum_open(UNUM_PATTERN_DECIMAL, pattern, 1, TEST_LOCALE, 0, &setupStatu s); },{ int32_t i; static UChar str[] = { 0x31 };double val; for(i=0;i <U_LOTS_OF_TIMES;i++) { val=unum_parse(NumParseTest_fmt,str,1,NULL,&setupSt atus); } return i; },{unum_close(NumParseTest_fmt);})
627 691
628 QuickTest(NumParseTestdot,{ static UChar pattern[] = { 0x23 }; NumParseTes t_fmt = unum_open(UNUM_PATTERN_DECIMAL, pattern, 1, "en_US", 0, &setupStatus ); },{ int32_t i; double val; for(i=0;i<U_LOTS_OF_TIMES;i++) { val= unum_parse(NumParseTest_fmt,strdot,1,NULL,&setupStatus); } return i; },{u num_close(NumParseTest_fmt);}) 692 QuickTest(NumParseTestdot,{ static UChar pattern[] = { 0x23 }; NumParseTes t_fmt = unum_open(UNUM_PATTERN_DECIMAL, pattern, 1, TEST_LOCALE, 0, &setupSt atus); },{ int32_t i; double val; for(i=0;i<U_LOTS_OF_TIMES;i++) { val=unum_parse(NumParseTest_fmt,strdot,1,NULL,&setupStatus); } return i; },{unum_close(NumParseTest_fmt);})
629 QuickTest(NumParseTestspc,{ static UChar pattern[] = { 0x23 }; NumParseTes t_fmt = unum_open(UNUM_PATTERN_DECIMAL, pattern, 1, "en_US", 0, &setupStatus ); },{ int32_t i; double val; for(i=0;i<U_LOTS_OF_TIMES;i++) { va l=unum_parse(NumParseTest_fmt,strspc,1,NULL,&setupStatus); } return i; }, {unum_close(NumParseTest_fmt);}) 693 QuickTest(NumParseTestspc,{ static UChar pattern[] = { 0x23 }; NumParseTes t_fmt = unum_open(UNUM_PATTERN_DECIMAL, pattern, 1, TEST_LOCALE, 0, &setupSt atus); },{ int32_t i; double val; for(i=0;i<U_LOTS_OF_TIMES;i++) { val=unum_parse(NumParseTest_fmt,strspc,1,NULL,&setupStatus); } return i; },{unum_close(NumParseTest_fmt);})
630 QuickTest(NumParseTestgrp,{ static UChar pattern[] = { 0x23 }; NumParseTes t_fmt = unum_open(UNUM_PATTERN_DECIMAL, pattern, 1, "en_US", 0, &setupStatus ); },{ int32_t i; double val; for(i=0;i<U_LOTS_OF_TIMES;i++) { va l=unum_parse(NumParseTest_fmt,strgrp,-1,NULL,&setupStatus); } return i; } ,{unum_close(NumParseTest_fmt);}) 694 QuickTest(NumParseTestgrp,{ static UChar pattern[] = { 0x23 }; NumParseTes t_fmt = unum_open(UNUM_PATTERN_DECIMAL, pattern, 1, TEST_LOCALE, 0, &setupSt atus); },{ int32_t i; double val; for(i=0;i<U_LOTS_OF_TIMES;i++) { val=unum_parse(NumParseTest_fmt,strgrp,-1,NULL,&setupStatus); } return i ; },{unum_close(NumParseTest_fmt);})
631 695
632 QuickTest(NumParseTestbeng,{ static UChar pattern[] = { 0x23 }; NumParseTe st_fmt = unum_open(UNUM_PATTERN_DECIMAL, pattern, 1, "en_US", 0, &setupStatu s); },{ int32_t i; double val; for(i=0;i<U_LOTS_OF_TIMES;i++) { v al=unum_parse(NumParseTest_fmt,strbeng,-1,NULL,&setupStatus); } return i; },{unum_close(NumParseTest_fmt);}) 696 QuickTest(NumParseTestbeng,{ static UChar pattern[] = { 0x23 }; NumParseTe st_fmt = unum_open(UNUM_PATTERN_DECIMAL, pattern, 1, TEST_LOCALE, 0, &setupS tatus); },{ int32_t i; double val; for(i=0;i<U_LOTS_OF_TIMES;i++) { val=unum_parse(NumParseTest_fmt,strbeng,-1,NULL,&setupStatus); } return i; },{unum_close(NumParseTest_fmt);})
633 697
634 UDateFormat *DateFormatTest_fmt = NULL; 698 UDateFormat *DateFormatTest_fmt = NULL;
635 UDate sometime = 100000000.0; 699 UDate sometime = 100000000.0;
636 UChar onekbuf[1024]; 700 UChar onekbuf[1024];
637 const int32_t onekbuf_len = sizeof(onekbuf)/sizeof(onekbuf[0]); 701 const int32_t onekbuf_len = sizeof(onekbuf)/sizeof(onekbuf[0]);
638 702
639 703
640 QuickTest(DateFormatTestBasic, \ 704 QuickTest(DateFormatTestBasic, \
641 { \ 705 { \
642 DateFormatTest_fmt = udat_open(UDAT_DEFAULT, UDAT_DEFAULT, NULL, NUL L, -1, NULL, -1, &setupStatus); \ 706 DateFormatTest_fmt = udat_open(UDAT_DEFAULT, UDAT_DEFAULT, NULL, NUL L, -1, NULL, -1, &setupStatus); \
643 }, \ 707 }, \
644 { \ 708 { \
645 int i; \ 709 int i; \
646 for(i=0;i<U_LOTS_OF_TIMES;i++) \ 710 for(i=0;i<U_LOTS_OF_TIMES;i++) \
647 { \ 711 { \
648 udat_format(DateFormatTest_fmt, sometime, onekbuf, onekbuf_len, NU LL, &setupStatus); \ 712 udat_format(DateFormatTest_fmt, sometime, onekbuf, onekbuf_len, NU LL, &setupStatus); \
649 } \ 713 } \
650 return i; \ 714 return i; \
651 }, \ 715 }, \
652 { \ 716 { \
653 udat_close(DateFormatTest_fmt); \ 717 udat_close(DateFormatTest_fmt); \
654 } \ 718 } \
655 ) 719 )
656 720
657 721
658 QuickTest(NullTest,{},{int j=U_LOTS_OF_TIMES;while(--j);return U_LOTS_OF_TIMES;} ,{}) 722 QuickTest(NullTest,{},{int j=U_LOTS_OF_TIMES;while(--j);return U_LOTS_OF_TIMES;} ,{})
659 723
660 #if 0 724 #if 0
661 #include <time.h> 725 #include <time.h>
662 726
663 QuickTest(RandomTest,{},{timespec ts; ts.tv_sec=rand()%4; int j=U_LOTS_OF_TIMES; while(--j) { ts.tv_nsec=100000+(rand()%10000)*1000000; nanosleep(&ts,NULL); retu rn j;} return U_LOTS_OF_TIMES;},{}) 727 QuickTest(RandomTest,{},{timespec ts; ts.tv_sec=rand()%4; int j=U_LOTS_OF_TIMES; while(--j) { ts.tv_nsec=100000+(rand()%10000)*1000000; nanosleep(&ts,NULL); retu rn j;} return U_LOTS_OF_TIMES;},{})
664 #endif 728 #endif
665 729
666 OpenCloseTest(pattern,unum,open,{},(UNUM_PATTERN_DECIMAL,pattern,1,"en_US",0,&se tupStatus),{}) 730 OpenCloseTest(pattern,unum,open,{},(UNUM_PATTERN_DECIMAL,pattern,1,TEST_LOCALE,0 ,&setupStatus),{})
667 OpenCloseTest(default,unum,open,{},(UNUM_DEFAULT,NULL,-1,"en_US",0,&setupStatus) ,{}) 731 OpenCloseTest(default,unum,open,{},(UNUM_DEFAULT,NULL,-1,TEST_LOCALE,0,&setupSta tus),{})
668 #if !UCONFIG_NO_CONVERSION 732 #if !UCONFIG_NO_CONVERSION
669 #include "unicode/ucnv.h" 733 #include "unicode/ucnv.h"
670 OpenCloseTest(gb18030,ucnv,open,{},("gb18030",&setupStatus),{}) 734 OpenCloseTest(gb18030,ucnv,open,{},("gb18030",&setupStatus),{})
671 #endif 735 #endif
672 #include "unicode/ures.h" 736 #include "unicode/ures.h"
673 OpenCloseTest(root,ures,open,{},(NULL,"root",&setupStatus),{}) 737 OpenCloseTest(root,ures,open,{},(NULL,"root",&setupStatus),{})
674 738
675 void runTests() { 739 void runTests() {
676 { 740 {
677 SieveTest t; 741 SieveTest t;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 783
720 784
721 // { NumParseTestgrp t; runTestOn(t); } 785 // { NumParseTestgrp t; runTestOn(t); }
722 { NumParseTestbeng t; runTestOn(t); } 786 { NumParseTestbeng t; runTestOn(t); }
723 787
724 } 788 }
725 #endif 789 #endif
726 790
727 #ifndef SKIP_NUMFORMAT_TESTS 791 #ifndef SKIP_NUMFORMAT_TESTS
728 // format tests 792 // format tests
729 { 793 {
730 794
731 DO_NumFmtInt64Test("0000","0001",1); 795 DO_NumFmtInt64Test("0000","0001",1);
732 DO_NumFmtInt64Test("0000","0000",0); 796 DO_NumFmtInt64Test("0000","0000",0);
733 StringPiece sp3456("3456"); 797 StringPiece sp3456("3456");
734 DO_NumFmtStringPieceTest("0000","3456",sp3456); 798 DO_NumFmtStringPieceTest("0000","3456",sp3456);
735 DO_NumFmtStringPieceTest("#","3456",sp3456); 799 DO_NumFmtStringPieceTest("#","3456",sp3456);
736 StringPiece sp3("3"); 800 StringPiece sp3("3");
737 DO_NumFmtStringPieceTest("0000","0003",sp3); 801 DO_NumFmtStringPieceTest("0000","0003",sp3);
738 DO_NumFmtStringPieceTest("#","3",sp3); 802 DO_NumFmtStringPieceTest("#","3",sp3);
739 StringPiece spn3("-3"); 803 StringPiece spn3("-3");
740 DO_NumFmtStringPieceTest("0000","-0003",spn3); 804 DO_NumFmtStringPieceTest("0000","-0003",spn3);
741 DO_NumFmtStringPieceTest("#","-3",spn3); 805 DO_NumFmtStringPieceTest("#","-3",spn3);
742 StringPiece spPI("123.456"); 806 StringPiece spPI("123.456");
743 DO_NumFmtStringPieceTest("#.0000","123.4560",spPI); 807 DO_NumFmtStringPieceTest("#.0000","123.4560",spPI);
744 DO_NumFmtStringPieceTest("#.00","123.46",spPI); 808 DO_NumFmtStringPieceTest("#.00","123.46",spPI);
745 809
746 DO_NumFmtTest("#","0",0.0); 810 DO_NumFmtTest("#","0",0.0);
747 DO_NumFmtTest("#","12345",12345); 811 DO_NumFmtTest("#","12345",12345);
748 DO_NumFmtTest("#","-2",-2); 812 DO_NumFmtTest("#","-2",-2);
749 DO_NumFmtTest("+#","+2",2); 813 DO_NumFmtTest("+#","+2",2);
814
750 DO_NumFmtInt64Test("#","-682",-682); 815 DO_NumFmtInt64Test("#","-682",-682);
751 DO_NumFmtInt64Test("#","0",0); 816 DO_NumFmtInt64Test("#","0",0);
752 DO_NumFmtInt64Test("#","12345",12345); 817 DO_NumFmtInt64Test("#","12345",12345);
818 DO_NumFmtInt64Test("#,###","12,345",12345);
753 DO_NumFmtInt64Test("#","1234",1234); 819 DO_NumFmtInt64Test("#","1234",1234);
754 DO_NumFmtInt64Test("#","123",123); 820 DO_NumFmtInt64Test("#","123",123);
821 DO_NumFmtInt64Test("#,###","123",123);
822 DO_NumFmtInt64Test_apply("#","123",123);
823 DO_NumFmtInt64Test_apply("#","12345",12345);
824 DO_NumFmtInt64Test_apply("#,###","123",123);
825 DO_NumFmtInt64Test_apply("#,###","12,345",12345);
826 DO_NumFmtInt64Test_default("","123",123);
827 DO_NumFmtInt64Test_default("","12,345",12345);
828 DO_NumFmtInt64Test_applygr0("#","123",123);
829 DO_NumFmtInt64Test_applygr0("#","12345",12345);
830 DO_NumFmtInt64Test_applygr0("#,###","123",123);
831 DO_NumFmtInt64Test_applygr0("#,###","12345",12345);
832 DO_NumFmtInt64Test_gr0("#","123",123);
833 DO_NumFmtInt64Test_gr0("#","12345",12345);
834 DO_NumFmtInt64Test_gr0("#,###","123",123);
835 DO_NumFmtInt64Test_gr0("#,###","12345",12345);
755 DO_NumFmtInt64Test("#","-2",-2); 836 DO_NumFmtInt64Test("#","-2",-2);
756 DO_NumFmtInt64Test("+#","+2",2); 837 DO_NumFmtInt64Test("+#","+2",2);
757 } 838 }
758 839
759 #ifndef SKIP_NUM_OPEN_TEST 840 #ifndef SKIP_NUM_OPEN_TEST
760 { 841 {
761 Test_unum_opendefault t; 842 Test_unum_opendefault t;
762 runTestOn(t); 843 runTestOn(t);
763 } 844 }
764 { 845 {
(...skipping 11 matching lines...) Expand all
776 #endif 857 #endif
777 { 858 {
778 Test_ures_openroot t; 859 Test_ures_openroot t;
779 runTestOn(t); 860 runTestOn(t);
780 } 861 }
781 862
782 if(testhit==0) { 863 if(testhit==0) {
783 fprintf(stderr, "ERROR: no tests matched.\n"); 864 fprintf(stderr, "ERROR: no tests matched.\n");
784 } 865 }
785 } 866 }
OLDNEW
« no previous file with comments | « source/test/perf/dicttrieperf/dicttrieperf.cpp ('k') | source/test/perf/normperf/dtfmtrtperf.vcxproj » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698