2 ***********************************************************************
3 * © 2016 and later: Unicode, Inc. and others.
4 * License & terms of use: http://www.unicode.org/copyright.html#License
5 ***********************************************************************
6 ***********************************************************************
7 * Copyright (c) 2011-2016,International Business Machines
8 * Corporation and others. All Rights Reserved.
9 ***********************************************************************
16 #include "unicode/utimer.h"
18 #include "unicode/ustring.h"
19 #include "unicode/decimfmt.h"
20 #include "unicode/udat.h"
23 #if U_PLATFORM_IMPLEMENTS_POSIX
26 static void usage(const char *prog
) {
27 fprintf(stderr
, "Usage: %s [ -f outfile.xml ] [ -t 'TestName' ]\n", prog
);
38 #define TEST_LOCALE "en_US"
42 UErrorCode setupStatus
= U_ZERO_ERROR
;
43 const char *outName
= NULL
;
45 const char *testName
= NULL
;
46 const char *progname
= NULL
;
50 int testMatch(const char *aName
) {
51 if(testName
==NULL
) return 1;
52 int len
= strlen(testName
);
53 if(testName
[len
-1]=='*') {
54 return strncmp(testName
,aName
,len
-1);
56 return strcmp(testName
,aName
);
60 int main(int argc
, char * const * argv
){
62 fprintf(stderr
,"%s: warning: U_DEBUG is on.\n", argv
[0]);
67 double s
= uprv_getSieveTime(&m
);
68 fprintf(stderr
, "** Standard sieve time: %.9fs +/- %.9fs (%d iterations)\n", s
,m
, (int)U_LOTS_OF_TIMES
);
72 #if U_PLATFORM_IMPLEMENTS_POSIX
76 while((c
=getopt(argc
,argv
,"lf:t:")) != EOF
) {
95 /* for ( ; optind < argc; optind++) { ... argv[optind] } */
100 fprintf(stderr
, "Err: usage: %s [ output-file.xml ]\n", argv
[0]);
104 if(listmode
&& outName
!= NULL
) {
105 fprintf(stderr
, "Warning: no output when list mode\n");
109 if(outName
!= NULL
) {
112 out
=fopen(outName
,"w");
114 fprintf(stderr
,"Err: can't open %s for writing.\n", outName
);
117 fprintf(stderr
, "# writing results to %s\n", outName
);
119 fprintf(out
, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
120 fprintf(out
, "<tests icu=\"%s\">\n", U_ICU_VERSION
);
121 fprintf(out
, "<!-- %s -->\n", U_COPYRIGHT_STRING
);
123 fprintf(stderr
, "# (no output)\n");
126 if(listmode
&& testName
!=NULL
) {
127 fprintf(stderr
, "ERR: no -l mode when specific test with -t\n");
138 udbg_writeIcuInfo(out
);
140 fprintf(out
, "</tests>\n");
144 if(U_FAILURE(setupStatus
)) {
145 fprintf(stderr
, "Error in tests: %s\n", u_errorName(setupStatus
));
152 class HowExpensiveTest
{
154 virtual ~HowExpensiveTest(){}
156 HowExpensiveTest(const char *name
, const char *file
, int32_t line
) : fName(name
), fFile(file
), fLine(line
) {}
159 * @return number of iterations
161 virtual int32_t run() = 0;
162 virtual void warmup() { run(); }
164 virtual const char *getName() { return fName
; }
166 virtual int32_t runTest(double *subTime
) {
169 int32_t iter
= run();
171 *subTime
= utimer_getDeltaSeconds(&a
,&b
);
175 virtual int32_t runTests(double *subTime
, double *marginOfError
) {
176 warmup(); /* warmup */
177 double times
[ITERATIONS
];
178 int subIterations
= 0;
179 for(int i
=0;i
<ITERATIONS
;i
++) {
180 subIterations
= runTest(×
[i
]);
182 fprintf(stderr
, "trial: %d/%d = %.9fs\n", i
, ITERATIONS
,times
[i
]);
186 uint32_t iterations
= ITERATIONS
;
187 *subTime
= uprv_getMeanTime(times
,&iterations
,marginOfError
);
188 return subIterations
;
197 void runTestOn(HowExpensiveTest
&t
) {
198 if(U_FAILURE(setupStatus
)) return; // silently
199 const char *tn
= t
.getName();
200 if(testName
!=NULL
&& testMatch(tn
)) return; // skipped.
202 fprintf(stderr
, "%s:%d:\t%s\n", t
.fFile
, t
.fLine
, t
.getName());
206 fprintf(stderr
, "%s:%d: Running: %s\n", t
.fFile
, t
.fLine
, t
.getName());
209 double sieveTime
= uprv_getSieveTime(NULL
);
215 int32_t iter
= t
.runTests(&st
,&me
);
216 if(U_FAILURE(setupStatus
)) {
217 fprintf(stderr
, "Error in tests: %s\n", u_errorName(setupStatus
));
223 double stn
= st
/sieveTime
;
225 printf("%s\t%.9f\t%.9f +/- %.9f, @ %d iter\n", t
.getName(),stn
,st
,me
,iter
);
228 fprintf(out
, " <test name=\"%s\" standardizedTime=\"%f\" realDuration=\"%f\" marginOfError=\"%f\" iterations=\"%d\" />\n",
234 /* ------------------- test code here --------------------- */
236 class SieveTest
: public HowExpensiveTest
{
238 virtual ~SieveTest(){}
239 SieveTest():HowExpensiveTest("SieveTest",__FILE__
,__LINE__
){}
240 virtual int32_t run(){return 0;} // dummy
241 int32_t runTest(double *subTime
) {
242 *subTime
= uprv_getSieveTime(NULL
);
243 return U_LOTS_OF_TIMES
;
245 virtual int32_t runTests(double *subTime
, double *marginOfError
) {
246 *subTime
= uprv_getSieveTime(marginOfError
);
247 return U_LOTS_OF_TIMES
;
252 /* ------- NumParseTest ------------- */
253 #include "unicode/unum.h"
254 /* open and close tests */
255 #define OCName(svc,ub,testn,suffix,n) testn ## svc ## ub ## suffix ## n
256 #define OCStr(svc,ub,suffix,n) "Test_" # svc # ub # suffix # n
257 #define OCRun(svc,ub,suffix) svc ## ub ## suffix
258 // TODO: run away screaming
259 #define OpenCloseTest(n, svc,suffix,c,a,d) class OCName(svc,_,Test_,suffix,n) : public HowExpensiveTest { public: OCName(svc,_,Test_,suffix,n)():HowExpensiveTest(OCStr(svc,_,suffix,n),__FILE__,__LINE__) c int32_t run() { int32_t i; for(i=0;i<U_LOTS_OF_TIMES;i++){ OCRun(svc,_,close) ( OCRun(svc,_,suffix) a ); } return i; } void warmup() { OCRun(svc,_,close) ( OCRun(svc,_,suffix) a); } virtual ~ OCName(svc,_,Test_,suffix,n) () d };
260 #define QuickTest(n,c,r,d) class n : public HowExpensiveTest { public: n():HowExpensiveTest(#n,__FILE__,__LINE__) c int32_t run() r virtual ~n () d };
262 class NumTest
: public HowExpensiveTest
{
267 UnicodeString fString
;
276 virtual const char *getName() {
278 sprintf(name
,"%s:p=|%s|,str=|%s|",getClassName(),fCPat
,fCStr
);
283 virtual UNumberFormat
* initFmt() {
284 return unum_open(UNUM_PATTERN_DECIMAL
, fPat
.getTerminatedBuffer(), -1, TEST_LOCALE
, 0, &setupStatus
);
286 virtual const char *getClassName() {
290 NumTest(const char *pat
, const char *num
, double expect
, const char *FILE, int LINE
)
291 : HowExpensiveTest("(n/a)",FILE, LINE
),
294 fPat(pat
, -1, US_INV
),
295 fString(num
,-1,US_INV
),
296 fStr(fString
.getTerminatedBuffer()),
297 fLen(u_strlen(fStr
)),
307 if(U_SUCCESS(setupStatus
)) {
308 double trial
= unum_parseDouble(fFmt
,fStr
,fLen
, NULL
, &setupStatus
);
309 if(U_SUCCESS(setupStatus
) && trial
!=fExpect
) {
310 setupStatus
= U_INTERNAL_PROGRAM_ERROR
;
311 printf("%s:%d: warmup() %s got %.8f expected %.8f\n",
312 fFile
,fLine
,getName(),trial
,fExpect
);
319 for(i
=0;i
<U_LOTS_OF_TIMES
;i
++){
320 trial
= unum_parse(fFmt
,fStr
,fLen
, NULL
, &setupStatus
);
327 #define DO_NumTest(p,n,x) { NumTest t(p,n,x,__FILE__,__LINE__); runTestOn(t); }
330 class AttrNumTest
: public NumTest
333 UNumberFormatAttribute fAttr
;
337 virtual const char *getClassName() {
338 sprintf(name2
,"AttrNumTest:%d=%d", fAttr
,fAttrValue
);
342 AttrNumTest(const char *pat
, const char *num
, double expect
, const char *FILE, int LINE
, UNumberFormatAttribute attr
, int32_t newValue
)
343 : NumTest(pat
,num
,expect
,FILE,LINE
),
348 virtual UNumberFormat
* initFmt() {
349 UNumberFormat
*fmt
= NumTest::initFmt();
350 unum_setAttribute(fmt
, fAttr
,fAttrValue
);
355 #define DO_AttrNumTest(p,n,x,a,v) { AttrNumTest t(p,n,x,__FILE__,__LINE__,a,v); runTestOn(t); }
358 class NOXNumTest
: public NumTest
361 UNumberFormatAttribute fAttr
;
365 virtual const char *getClassName() {
366 sprintf(name2
,"NOXNumTest:%d=%d", fAttr
,fAttrValue
);
370 NOXNumTest(const char *pat
, const char *num
, double expect
, const char *FILE, int LINE
/*, UNumberFormatAttribute attr, int32_t newValue */)
371 : NumTest(pat
,num
,expect
,FILE,LINE
) /* ,
373 fAttrValue(newValue) */
376 virtual UNumberFormat
* initFmt() {
377 UNumberFormat
*fmt
= NumTest::initFmt();
378 //unum_setAttribute(fmt, fAttr,fAttrValue);
383 #define DO_NOXNumTest(p,n,x) { NOXNumTest t(p,n,x,__FILE__,__LINE__); runTestOn(t); }
385 #define DO_TripleNumTest(p,n,x) DO_AttrNumTest(p,n,x,UNUM_PARSE_ALL_INPUT,UNUM_YES) \
386 DO_AttrNumTest(p,n,x,UNUM_PARSE_ALL_INPUT,UNUM_NO) \
387 DO_AttrNumTest(p,n,x,UNUM_PARSE_ALL_INPUT,UNUM_MAYBE)
390 class NumFmtTest
: public HowExpensiveTest
{
395 UnicodeString fString
;
404 virtual const char *getName() {
406 sprintf(name
,"%s:p=|%s|,str=|%s|",getClassName(),fCPat
,fCStr
);
411 virtual UNumberFormat
* initFmt() {
412 return unum_open(UNUM_PATTERN_DECIMAL
, fPat
.getTerminatedBuffer(), -1, TEST_LOCALE
, 0, &setupStatus
);
414 virtual const char *getClassName() {
418 NumFmtTest(const char *pat
, const char *num
, double expect
, const char *FILE, int LINE
)
419 : HowExpensiveTest("(n/a)",FILE, LINE
),
422 fPat(pat
, -1, US_INV
),
423 fString(num
,-1,US_INV
),
424 fStr(fString
.getTerminatedBuffer()),
425 fLen(u_strlen(fStr
)),
436 if(U_SUCCESS(setupStatus
)) {
437 int32_t trial
= unum_formatDouble(fFmt
,fExpect
, buf
, 100, NULL
, &setupStatus
);
438 if(!U_SUCCESS(setupStatus
)
441 || u_strncmp(fStr
,buf
,trial
) ) {
443 u_strToUTF8(strBuf
,200,NULL
,buf
,trial
+1,&setupStatus
);
444 printf("%s:%d: warmup() %s got %s expected %s, err %s\n",
445 fFile
,fLine
,getName(),strBuf
,fCStr
, u_errorName(setupStatus
));
446 setupStatus
= U_INTERNAL_PROGRAM_ERROR
;
454 if(U_SUCCESS(setupStatus
)) {
455 for(i
=0;i
<U_LOTS_OF_TIMES
;i
++){
456 trial
= unum_formatDouble(fFmt
,fExpect
, buf
, 100, NULL
, &setupStatus
);
461 virtual ~NumFmtTest(){}
464 #define DO_NumFmtTest(p,n,x) { NumFmtTest t(p,n,x,__FILE__,__LINE__); runTestOn(t); }
466 class NumFmtInt64Test
: public HowExpensiveTest
{
480 UnicodeString fString
;
489 virtual const char *getName() {
491 sprintf(name
,"%s:p=|%s|,str=|%s|",getClassName(),fCPat
,fCStr
);
496 virtual UNumberFormat
* initFmt() {
499 return unum_open(UNUM_PATTERN_DECIMAL
, fPat
.getTerminatedBuffer(), -1, TEST_LOCALE
, 0, &setupStatus
);
502 UNumberFormat
*fmt
= unum_open(UNUM_DECIMAL
, NULL
, -1, TEST_LOCALE
, 0, &setupStatus
);
503 unum_applyPattern(fmt
, FALSE
, fPat
.getTerminatedBuffer(), -1, NULL
, &setupStatus
);
508 UNumberFormat
*fmt
= unum_open(UNUM_PATTERN_DECIMAL
, fPat
.getTerminatedBuffer(), -1, TEST_LOCALE
, 0, &setupStatus
);
509 unum_setAttribute(fmt
, UNUM_GROUPING_USED
, UNUM_NO
);
514 UNumberFormat
*fmt
= unum_open(UNUM_DECIMAL
, NULL
, -1, TEST_LOCALE
, 0, &setupStatus
);
515 unum_applyPattern(fmt
, FALSE
, fPat
.getTerminatedBuffer(), -1, NULL
, &setupStatus
);
516 unum_setAttribute(fmt
, UNUM_GROUPING_USED
, UNUM_NO
);
521 return unum_open(UNUM_DEFAULT
, NULL
, -1, TEST_LOCALE
, 0, &setupStatus
);
524 virtual const char *getClassName() {
526 case EMode::kDefault
:
527 return "NumFmtInt64Test (default)";
528 case EMode::kPattern
:
529 return "NumFmtInt64Test (pattern)";
530 case EMode::kApplyPattern
:
531 return "NumFmtInt64Test (applypattern)";
532 case EMode::kGroupOff
:
533 return "NumFmtInt64Test (pattern, group=off)";
534 case EMode::kApplyGroupOff
:
535 return "NumFmtInt64Test (applypattern, group=off)";
537 return "NumFmtInt64Test (? ? ?)";
541 NumFmtInt64Test(const char *pat
, const char *num
, int64_t expect
, const char *FILE, int LINE
, EMode mode
)
542 : HowExpensiveTest("(n/a)",FILE, LINE
),
546 fPat(pat
, -1, US_INV
),
547 fString(num
,-1,US_INV
),
548 fStr(fString
.getTerminatedBuffer()),
549 fLen(u_strlen(fStr
)),
560 if(U_SUCCESS(setupStatus
)) {
561 int32_t trial
= unum_formatInt64(fFmt
,fExpect
, buf
, 100, NULL
, &setupStatus
);
562 if(!U_SUCCESS(setupStatus
)
565 || u_strncmp(fStr
,buf
,trial
) ) {
567 u_strToUTF8(strBuf
,200,NULL
,buf
,trial
+1,&setupStatus
);
568 printf("%s:%d: warmup() %s got %s (len %d) expected %s (len %d), err %s\n",
569 fFile
,fLine
,getName(),strBuf
,trial
,fCStr
,fLen
, u_errorName(setupStatus
));
570 setupStatus
= U_INTERNAL_PROGRAM_ERROR
;
578 if(U_SUCCESS(setupStatus
)) {
579 for(i
=0;i
<U_LOTS_OF_TIMES
;i
++){
580 trial
= unum_formatInt64(fFmt
,fExpect
, buf
, 100, NULL
, &setupStatus
);
585 virtual ~NumFmtInt64Test(){}
589 * unum_open .. with pattern, == new DecimalFormat(pattern)
591 #define DO_NumFmtInt64Test(p,n,x) { NumFmtInt64Test t(p,n,x,__FILE__,__LINE__,NumFmtInt64Test::EMode::kPattern); runTestOn(t); }
593 * unum_open(UNUM_DECIMAL), then
595 #define DO_NumFmtInt64Test_apply(p,n,x) { NumFmtInt64Test t(p,n,x,__FILE__,__LINE__,NumFmtInt64Test::EMode::kApplyPattern); runTestOn(t); }
597 #define DO_NumFmtInt64Test_default(p,n,x) { NumFmtInt64Test t(p,n,x,__FILE__,__LINE__,NumFmtInt64Test::EMode::kDefault); runTestOn(t); }
598 #define DO_NumFmtInt64Test_gr0(p,n,x) { NumFmtInt64Test t(p,n,x,__FILE__,__LINE__,NumFmtInt64Test::EMode::kGroupOff); runTestOn(t); }
599 #define DO_NumFmtInt64Test_applygr0(p,n,x) { NumFmtInt64Test t(p,n,x,__FILE__,__LINE__,NumFmtInt64Test::EMode::kApplyGroupOff); runTestOn(t); }
602 class NumFmtStringPieceTest
: public HowExpensiveTest
{
604 const StringPiece
&fExpect
;
607 UnicodeString fString
;
616 virtual const char *getName() {
618 sprintf(name
,"%s:p=|%s|,str=|%s|,sp=|%s|",getClassName(),fCPat
,fCStr
, fExpect
.data());
623 virtual UNumberFormat
* initFmt() {
624 DecimalFormat
*d
= new DecimalFormat(setupStatus
);
626 d
->applyPattern(fPat
, pe
, setupStatus
);
627 return (UNumberFormat
*) d
;
629 virtual const char *getClassName() {
630 return "NumFmtStringPieceTest";
633 NumFmtStringPieceTest(const char *pat
, const char *num
, const StringPiece
& expect
, const char *FILE, int LINE
)
634 : HowExpensiveTest("(n/a)",FILE, LINE
),
637 fPat(pat
, -1, US_INV
),
638 fString(num
,-1,US_INV
),
639 fStr(fString
.getTerminatedBuffer()),
640 fLen(u_strlen(fStr
)),
651 if(U_SUCCESS(setupStatus
)) {
653 ((const DecimalFormat
*)fFmt
)->format(fExpect
, buf
, NULL
, setupStatus
);
654 if(!U_SUCCESS(setupStatus
)
658 u_strToUTF8(strBuf
,200,NULL
,buf
.getTerminatedBuffer(),buf
.length()+1,&setupStatus
);
659 printf("%s:%d: warmup() %s got %s (len %d) expected %s (len %d), err %s\n",
660 fFile
,fLine
,getName(),strBuf
,buf
.length(),fCStr
,fLen
, u_errorName(setupStatus
));
661 setupStatus
= U_INTERNAL_PROGRAM_ERROR
;
672 if(U_SUCCESS(setupStatus
)) {
673 for(i
=0;i
<U_LOTS_OF_TIMES
;i
++){
675 ((const DecimalFormat
*)fFmt
)->format(fExpect
, buf
, NULL
, setupStatus
);
680 virtual ~NumFmtStringPieceTest(){}
683 #define DO_NumFmtStringPieceTest(p,n,x) { NumFmtStringPieceTest t(p,n,x,__FILE__,__LINE__); runTestOn(t); }
685 // TODO: move, scope.
686 static UChar pattern
[] = { 0x23 }; // '#'
687 static UChar strdot
[] = { '2', '.', '0', 0 };
688 static UChar strspc
[] = { '2', ' ', 0 };
689 static UChar strgrp
[] = {'2',',','2','2','2', 0 };
690 static UChar strbeng
[] = {0x09E8,0x09E8,0x09E8,0x09E8, 0 };
692 UNumberFormat
*NumParseTest_fmt
;
695 QuickTest(NumParseTest
,{ static UChar pattern
[] = { 0x23 }; NumParseTest_fmt
= unum_open(UNUM_PATTERN_DECIMAL
, pattern
, 1, TEST_LOCALE
, 0, &setupStatus
); },{ 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
,&setupStatus
); } return i
; },{unum_close(NumParseTest_fmt
);})
697 QuickTest(NumParseTestdot
,{ static UChar pattern
[] = { 0x23 }; NumParseTest_fmt
= unum_open(UNUM_PATTERN_DECIMAL
, pattern
, 1, TEST_LOCALE
, 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
; },{unum_close(NumParseTest_fmt
);})
698 QuickTest(NumParseTestspc
,{ static UChar pattern
[] = { 0x23 }; NumParseTest_fmt
= unum_open(UNUM_PATTERN_DECIMAL
, pattern
, 1, TEST_LOCALE
, 0, &setupStatus
); },{ 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
);})
699 QuickTest(NumParseTestgrp
,{ static UChar pattern
[] = { 0x23 }; NumParseTest_fmt
= unum_open(UNUM_PATTERN_DECIMAL
, pattern
, 1, TEST_LOCALE
, 0, &setupStatus
); },{ 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
);})
701 QuickTest(NumParseTestbeng
,{ static UChar pattern
[] = { 0x23 }; NumParseTest_fmt
= unum_open(UNUM_PATTERN_DECIMAL
, pattern
, 1, TEST_LOCALE
, 0, &setupStatus
); },{ 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
);})
703 UDateFormat
*DateFormatTest_fmt
= NULL
;
704 UDate sometime
= 100000000.0;
706 const int32_t onekbuf_len
= UPRV_LENGTHOF(onekbuf
);
709 QuickTest(DateFormatTestBasic
, \
711 DateFormatTest_fmt
= udat_open(UDAT_DEFAULT
, UDAT_DEFAULT
, NULL
, NULL
, -1, NULL
, -1, &setupStatus
); \
715 for(i
=0;i
<U_LOTS_OF_TIMES
;i
++) \
717 udat_format(DateFormatTest_fmt
, sometime
, onekbuf
, onekbuf_len
, NULL
, &setupStatus
); \
722 udat_close(DateFormatTest_fmt
); \
727 QuickTest(NullTest
,{},{int j
=U_LOTS_OF_TIMES
;while(--j
);return U_LOTS_OF_TIMES
;},{})
732 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
); return j
;} return U_LOTS_OF_TIMES
;},{})
735 OpenCloseTest(pattern
,unum
,open
,{},(UNUM_PATTERN_DECIMAL
,pattern
,1,TEST_LOCALE
,0,&setupStatus
),{})
736 OpenCloseTest(default,unum
,open
,{},(UNUM_DEFAULT
,NULL
,-1,TEST_LOCALE
,0,&setupStatus
),{})
737 #if !UCONFIG_NO_CONVERSION
738 #include "unicode/ucnv.h"
739 OpenCloseTest(gb18030
,ucnv
,open
,{},("gb18030",&setupStatus
),{})
741 #include "unicode/ures.h"
742 OpenCloseTest(root
,ures
,open
,{},(NULL
,"root",&setupStatus
),{})
760 #ifndef SKIP_DATEFMT_TESTS
762 DateFormatTestBasic t
;
767 #ifndef SKIP_NUMPARSE_TESTS
771 DO_NumTest("#","0",0.0);
772 DO_NumTest("#","2.0",2.0);
773 DO_NumTest("#","2 ",2);
774 DO_NumTest("#","-2 ",-2);
775 DO_NumTest("+#","+2",2);
776 DO_NumTest("#,###.0","2222.0",2222.0);
777 DO_NumTest("#.0","1.000000000000000000000000000000000000000000000000000000000000000000000000000000",1.0);
778 DO_NumTest("#","123456",123456);
781 #ifdef HAVE_UNUM_MAYBE
782 DO_AttrNumTest("#","0",0.0,UNUM_PARSE_ALL_INPUT
,UNUM_YES
);
783 DO_AttrNumTest("#","0",0.0,UNUM_PARSE_ALL_INPUT
,UNUM_NO
);
784 DO_AttrNumTest("#","0",0.0,UNUM_PARSE_ALL_INPUT
,UNUM_MAYBE
);
785 DO_TripleNumTest("#","2.0",2.0);
786 DO_AttrNumTest("#.0","1.000000000000000000000000000000000000000000000000000000000000000000000000000000",1.0,UNUM_PARSE_ALL_INPUT
,UNUM_NO
);
790 // { NumParseTestgrp t; runTestOn(t); }
791 { NumParseTestbeng t
; runTestOn(t
); }
796 #ifndef SKIP_NUMFORMAT_TESTS
800 DO_NumFmtInt64Test("0000","0001",1);
801 DO_NumFmtInt64Test("0000","0000",0);
802 StringPiece
sp3456("3456");
803 DO_NumFmtStringPieceTest("0000","3456",sp3456
);
804 DO_NumFmtStringPieceTest("#","3456",sp3456
);
805 StringPiece
sp3("3");
806 DO_NumFmtStringPieceTest("0000","0003",sp3
);
807 DO_NumFmtStringPieceTest("#","3",sp3
);
808 StringPiece
spn3("-3");
809 DO_NumFmtStringPieceTest("0000","-0003",spn3
);
810 DO_NumFmtStringPieceTest("#","-3",spn3
);
811 StringPiece
spPI("123.456");
812 DO_NumFmtStringPieceTest("#.0000","123.4560",spPI
);
813 DO_NumFmtStringPieceTest("#.00","123.46",spPI
);
815 DO_NumFmtTest("#","0",0.0);
816 DO_NumFmtTest("#","12345",12345);
817 DO_NumFmtTest("#","-2",-2);
818 DO_NumFmtTest("+#","+2",2);
820 DO_NumFmtInt64Test("#","-682",-682);
821 DO_NumFmtInt64Test("#","0",0);
822 DO_NumFmtInt64Test("#","12345",12345);
823 DO_NumFmtInt64Test("#,###","12,345",12345);
824 DO_NumFmtInt64Test("#","1234",1234);
825 DO_NumFmtInt64Test("#","123",123);
826 DO_NumFmtInt64Test("#,###","123",123);
827 DO_NumFmtInt64Test_apply("#","123",123);
828 DO_NumFmtInt64Test_apply("#","12345",12345);
829 DO_NumFmtInt64Test_apply("#,###","123",123);
830 DO_NumFmtInt64Test_apply("#,###","12,345",12345);
831 DO_NumFmtInt64Test_default("","123",123);
832 DO_NumFmtInt64Test_default("","12,345",12345);
833 DO_NumFmtInt64Test_applygr0("#","123",123);
834 DO_NumFmtInt64Test_applygr0("#","12345",12345);
835 DO_NumFmtInt64Test_applygr0("#,###","123",123);
836 DO_NumFmtInt64Test_applygr0("#,###","12345",12345);
837 DO_NumFmtInt64Test_gr0("#","123",123);
838 DO_NumFmtInt64Test_gr0("#","12345",12345);
839 DO_NumFmtInt64Test_gr0("#,###","123",123);
840 DO_NumFmtInt64Test_gr0("#,###","12345",12345);
841 DO_NumFmtInt64Test("#","-2",-2);
842 DO_NumFmtInt64Test("+#","+2",2);
845 #ifndef SKIP_NUM_OPEN_TEST
847 Test_unum_opendefault t
;
851 Test_unum_openpattern t
;
856 #endif /* skip numformat tests */
857 #if !UCONFIG_NO_CONVERSION
859 Test_ucnv_opengb18030 t
;
864 Test_ures_openroot t
;
869 fprintf(stderr
, "ERROR: no tests matched.\n");