2 **********************************************************************
3 * Copyright (c) 2011-2014,International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
11 #include "unicode/utimer.h"
13 #include "unicode/ustring.h"
14 #include "unicode/decimfmt.h"
15 #include "unicode/udat.h"
18 #if U_PLATFORM_IMPLEMENTS_POSIX
21 static void usage(const char *prog
) {
22 fprintf(stderr
, "Usage: %s [ -f outfile.xml ] [ -t 'TestName' ]\n", prog
);
33 #define TEST_LOCALE "en_US"
37 UErrorCode setupStatus
= U_ZERO_ERROR
;
38 const char *outName
= NULL
;
40 const char *testName
= NULL
;
41 const char *progname
= NULL
;
45 int testMatch(const char *aName
) {
46 if(testName
==NULL
) return 1;
47 int len
= strlen(testName
);
48 if(testName
[len
-1]=='*') {
49 return strncmp(testName
,aName
,len
-1);
51 return strcmp(testName
,aName
);
55 int main(int argc
, char * const * argv
){
57 fprintf(stderr
,"%s: warning: U_DEBUG is on.\n", argv
[0]);
62 double s
= uprv_getSieveTime(&m
);
63 fprintf(stderr
, "** Standard sieve time: %.9fs +/- %.9fs (%d iterations)\n", s
,m
, (int)U_LOTS_OF_TIMES
);
67 #if U_PLATFORM_IMPLEMENTS_POSIX
71 while((c
=getopt(argc
,argv
,"lf:t:")) != EOF
) {
90 /* for ( ; optind < argc; optind++) { ... argv[optind] } */
95 fprintf(stderr
, "Err: usage: %s [ output-file.xml ]\n", argv
[0]);
99 if(listmode
&& outName
!= NULL
) {
100 fprintf(stderr
, "Warning: no output when list mode\n");
104 if(outName
!= NULL
) {
107 out
=fopen(outName
,"w");
109 fprintf(stderr
,"Err: can't open %s for writing.\n", outName
);
112 fprintf(stderr
, "# writing results to %s\n", outName
);
114 fprintf(out
, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
115 fprintf(out
, "<tests icu=\"%s\">\n", U_ICU_VERSION
);
116 fprintf(out
, "<!-- %s -->\n", U_COPYRIGHT_STRING
);
118 fprintf(stderr
, "# (no output)\n");
121 if(listmode
&& testName
!=NULL
) {
122 fprintf(stderr
, "ERR: no -l mode when specific test with -t\n");
133 udbg_writeIcuInfo(out
);
135 fprintf(out
, "</tests>\n");
139 if(U_FAILURE(setupStatus
)) {
140 fprintf(stderr
, "Error in tests: %s\n", u_errorName(setupStatus
));
147 class HowExpensiveTest
{
149 virtual ~HowExpensiveTest(){}
151 HowExpensiveTest(const char *name
, const char *file
, int32_t line
) : fName(name
), fFile(file
), fLine(line
) {}
154 * @return number of iterations
156 virtual int32_t run() = 0;
157 virtual void warmup() { run(); }
159 virtual const char *getName() { return fName
; }
161 virtual int32_t runTest(double *subTime
) {
164 int32_t iter
= run();
166 *subTime
= utimer_getDeltaSeconds(&a
,&b
);
170 virtual int32_t runTests(double *subTime
, double *marginOfError
) {
171 warmup(); /* warmup */
172 double times
[ITERATIONS
];
173 int subIterations
= 0;
174 for(int i
=0;i
<ITERATIONS
;i
++) {
175 subIterations
= runTest(×
[i
]);
177 fprintf(stderr
, "trial: %d/%d = %.9fs\n", i
, ITERATIONS
,times
[i
]);
181 uint32_t iterations
= ITERATIONS
;
182 *subTime
= uprv_getMeanTime(times
,&iterations
,marginOfError
);
183 return subIterations
;
192 void runTestOn(HowExpensiveTest
&t
) {
193 if(U_FAILURE(setupStatus
)) return; // silently
194 const char *tn
= t
.getName();
195 if(testName
!=NULL
&& testMatch(tn
)) return; // skipped.
197 fprintf(stderr
, "%s:%d:\t%s\n", t
.fFile
, t
.fLine
, t
.getName());
201 fprintf(stderr
, "%s:%d: Running: %s\n", t
.fFile
, t
.fLine
, t
.getName());
204 double sieveTime
= uprv_getSieveTime(NULL
);
210 int32_t iter
= t
.runTests(&st
,&me
);
211 if(U_FAILURE(setupStatus
)) {
212 fprintf(stderr
, "Error in tests: %s\n", u_errorName(setupStatus
));
218 double stn
= st
/sieveTime
;
220 printf("%s\t%.9f\t%.9f +/- %.9f, @ %d iter\n", t
.getName(),stn
,st
,me
,iter
);
223 fprintf(out
, " <test name=\"%s\" standardizedTime=\"%f\" realDuration=\"%f\" marginOfError=\"%f\" iterations=\"%d\" />\n",
229 /* ------------------- test code here --------------------- */
231 class SieveTest
: public HowExpensiveTest
{
233 virtual ~SieveTest(){}
234 SieveTest():HowExpensiveTest("SieveTest",__FILE__
,__LINE__
){}
235 virtual int32_t run(){return 0;} // dummy
236 int32_t runTest(double *subTime
) {
237 *subTime
= uprv_getSieveTime(NULL
);
238 return U_LOTS_OF_TIMES
;
240 virtual int32_t runTests(double *subTime
, double *marginOfError
) {
241 *subTime
= uprv_getSieveTime(marginOfError
);
242 return U_LOTS_OF_TIMES
;
247 /* ------- NumParseTest ------------- */
248 #include "unicode/unum.h"
249 /* open and close tests */
250 #define OCName(svc,ub,testn,suffix,n) testn ## svc ## ub ## suffix ## n
251 #define OCStr(svc,ub,suffix,n) "Test_" # svc # ub # suffix # n
252 #define OCRun(svc,ub,suffix) svc ## ub ## suffix
253 // TODO: run away screaming
254 #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 };
255 #define QuickTest(n,c,r,d) class n : public HowExpensiveTest { public: n():HowExpensiveTest(#n,__FILE__,__LINE__) c int32_t run() r virtual ~n () d };
257 class NumTest
: public HowExpensiveTest
{
262 UnicodeString fString
;
271 virtual const char *getName() {
273 sprintf(name
,"%s:p=|%s|,str=|%s|",getClassName(),fCPat
,fCStr
);
278 virtual UNumberFormat
* initFmt() {
279 return unum_open(UNUM_PATTERN_DECIMAL
, fPat
.getTerminatedBuffer(), -1, TEST_LOCALE
, 0, &setupStatus
);
281 virtual const char *getClassName() {
285 NumTest(const char *pat
, const char *num
, double expect
, const char *FILE, int LINE
)
286 : HowExpensiveTest("(n/a)",FILE, LINE
),
289 fPat(pat
, -1, US_INV
),
290 fString(num
,-1,US_INV
),
291 fStr(fString
.getTerminatedBuffer()),
292 fLen(u_strlen(fStr
)),
302 if(U_SUCCESS(setupStatus
)) {
303 double trial
= unum_parseDouble(fFmt
,fStr
,fLen
, NULL
, &setupStatus
);
304 if(U_SUCCESS(setupStatus
) && trial
!=fExpect
) {
305 setupStatus
= U_INTERNAL_PROGRAM_ERROR
;
306 printf("%s:%d: warmup() %s got %.8f expected %.8f\n",
307 fFile
,fLine
,getName(),trial
,fExpect
);
314 for(i
=0;i
<U_LOTS_OF_TIMES
;i
++){
315 trial
= unum_parse(fFmt
,fStr
,fLen
, NULL
, &setupStatus
);
322 #define DO_NumTest(p,n,x) { NumTest t(p,n,x,__FILE__,__LINE__); runTestOn(t); }
325 class AttrNumTest
: public NumTest
328 UNumberFormatAttribute fAttr
;
332 virtual const char *getClassName() {
333 sprintf(name2
,"AttrNumTest:%d=%d", fAttr
,fAttrValue
);
337 AttrNumTest(const char *pat
, const char *num
, double expect
, const char *FILE, int LINE
, UNumberFormatAttribute attr
, int32_t newValue
)
338 : NumTest(pat
,num
,expect
,FILE,LINE
),
343 virtual UNumberFormat
* initFmt() {
344 UNumberFormat
*fmt
= NumTest::initFmt();
345 unum_setAttribute(fmt
, fAttr
,fAttrValue
);
350 #define DO_AttrNumTest(p,n,x,a,v) { AttrNumTest t(p,n,x,__FILE__,__LINE__,a,v); runTestOn(t); }
353 class NOXNumTest
: public NumTest
356 UNumberFormatAttribute fAttr
;
360 virtual const char *getClassName() {
361 sprintf(name2
,"NOXNumTest:%d=%d", fAttr
,fAttrValue
);
365 NOXNumTest(const char *pat
, const char *num
, double expect
, const char *FILE, int LINE
/*, UNumberFormatAttribute attr, int32_t newValue */)
366 : NumTest(pat
,num
,expect
,FILE,LINE
) /* ,
368 fAttrValue(newValue) */
371 virtual UNumberFormat
* initFmt() {
372 UNumberFormat
*fmt
= NumTest::initFmt();
373 //unum_setAttribute(fmt, fAttr,fAttrValue);
378 #define DO_NOXNumTest(p,n,x) { NOXNumTest t(p,n,x,__FILE__,__LINE__); runTestOn(t); }
380 #define DO_TripleNumTest(p,n,x) DO_AttrNumTest(p,n,x,UNUM_PARSE_ALL_INPUT,UNUM_YES) \
381 DO_AttrNumTest(p,n,x,UNUM_PARSE_ALL_INPUT,UNUM_NO) \
382 DO_AttrNumTest(p,n,x,UNUM_PARSE_ALL_INPUT,UNUM_MAYBE)
385 class NumFmtTest
: public HowExpensiveTest
{
390 UnicodeString fString
;
399 virtual const char *getName() {
401 sprintf(name
,"%s:p=|%s|,str=|%s|",getClassName(),fCPat
,fCStr
);
406 virtual UNumberFormat
* initFmt() {
407 return unum_open(UNUM_PATTERN_DECIMAL
, fPat
.getTerminatedBuffer(), -1, TEST_LOCALE
, 0, &setupStatus
);
409 virtual const char *getClassName() {
413 NumFmtTest(const char *pat
, const char *num
, double expect
, const char *FILE, int LINE
)
414 : HowExpensiveTest("(n/a)",FILE, LINE
),
417 fPat(pat
, -1, US_INV
),
418 fString(num
,-1,US_INV
),
419 fStr(fString
.getTerminatedBuffer()),
420 fLen(u_strlen(fStr
)),
431 if(U_SUCCESS(setupStatus
)) {
432 int32_t trial
= unum_formatDouble(fFmt
,fExpect
, buf
, 100, NULL
, &setupStatus
);
433 if(!U_SUCCESS(setupStatus
)
436 || u_strncmp(fStr
,buf
,trial
) ) {
438 u_strToUTF8(strBuf
,200,NULL
,buf
,trial
+1,&setupStatus
);
439 printf("%s:%d: warmup() %s got %s expected %s, err %s\n",
440 fFile
,fLine
,getName(),strBuf
,fCStr
, u_errorName(setupStatus
));
441 setupStatus
= U_INTERNAL_PROGRAM_ERROR
;
449 if(U_SUCCESS(setupStatus
)) {
450 for(i
=0;i
<U_LOTS_OF_TIMES
;i
++){
451 trial
= unum_formatDouble(fFmt
,fExpect
, buf
, 100, NULL
, &setupStatus
);
456 virtual ~NumFmtTest(){}
459 #define DO_NumFmtTest(p,n,x) { NumFmtTest t(p,n,x,__FILE__,__LINE__); runTestOn(t); }
461 class NumFmtInt64Test
: public HowExpensiveTest
{
475 UnicodeString fString
;
484 virtual const char *getName() {
486 sprintf(name
,"%s:p=|%s|,str=|%s|",getClassName(),fCPat
,fCStr
);
491 virtual UNumberFormat
* initFmt() {
494 return unum_open(UNUM_PATTERN_DECIMAL
, fPat
.getTerminatedBuffer(), -1, TEST_LOCALE
, 0, &setupStatus
);
497 UNumberFormat
*fmt
= unum_open(UNUM_DECIMAL
, NULL
, -1, TEST_LOCALE
, 0, &setupStatus
);
498 unum_applyPattern(fmt
, FALSE
, fPat
.getTerminatedBuffer(), -1, NULL
, &setupStatus
);
503 UNumberFormat
*fmt
= unum_open(UNUM_PATTERN_DECIMAL
, fPat
.getTerminatedBuffer(), -1, TEST_LOCALE
, 0, &setupStatus
);
504 unum_setAttribute(fmt
, UNUM_GROUPING_USED
, UNUM_NO
);
509 UNumberFormat
*fmt
= unum_open(UNUM_DECIMAL
, NULL
, -1, TEST_LOCALE
, 0, &setupStatus
);
510 unum_applyPattern(fmt
, FALSE
, fPat
.getTerminatedBuffer(), -1, NULL
, &setupStatus
);
511 unum_setAttribute(fmt
, UNUM_GROUPING_USED
, UNUM_NO
);
516 return unum_open(UNUM_DEFAULT
, NULL
, -1, TEST_LOCALE
, 0, &setupStatus
);
519 virtual const char *getClassName() {
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)";
532 return "NumFmtInt64Test (? ? ?)";
536 NumFmtInt64Test(const char *pat
, const char *num
, int64_t expect
, const char *FILE, int LINE
, EMode mode
)
537 : HowExpensiveTest("(n/a)",FILE, LINE
),
541 fPat(pat
, -1, US_INV
),
542 fString(num
,-1,US_INV
),
543 fStr(fString
.getTerminatedBuffer()),
544 fLen(u_strlen(fStr
)),
555 if(U_SUCCESS(setupStatus
)) {
556 int32_t trial
= unum_formatInt64(fFmt
,fExpect
, buf
, 100, NULL
, &setupStatus
);
557 if(!U_SUCCESS(setupStatus
)
560 || u_strncmp(fStr
,buf
,trial
) ) {
562 u_strToUTF8(strBuf
,200,NULL
,buf
,trial
+1,&setupStatus
);
563 printf("%s:%d: warmup() %s got %s (len %d) expected %s (len %d), err %s\n",
564 fFile
,fLine
,getName(),strBuf
,trial
,fCStr
,fLen
, u_errorName(setupStatus
));
565 setupStatus
= U_INTERNAL_PROGRAM_ERROR
;
573 if(U_SUCCESS(setupStatus
)) {
574 for(i
=0;i
<U_LOTS_OF_TIMES
;i
++){
575 trial
= unum_formatInt64(fFmt
,fExpect
, buf
, 100, NULL
, &setupStatus
);
580 virtual ~NumFmtInt64Test(){}
584 * unum_open .. with pattern, == new DecimalFormat(pattern)
586 #define DO_NumFmtInt64Test(p,n,x) { NumFmtInt64Test t(p,n,x,__FILE__,__LINE__,NumFmtInt64Test::EMode::kPattern); runTestOn(t); }
588 * unum_open(UNUM_DECIMAL), then
590 #define DO_NumFmtInt64Test_apply(p,n,x) { NumFmtInt64Test t(p,n,x,__FILE__,__LINE__,NumFmtInt64Test::EMode::kApplyPattern); runTestOn(t); }
592 #define DO_NumFmtInt64Test_default(p,n,x) { NumFmtInt64Test t(p,n,x,__FILE__,__LINE__,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); }
597 class NumFmtStringPieceTest
: public HowExpensiveTest
{
599 const StringPiece
&fExpect
;
602 UnicodeString fString
;
611 virtual const char *getName() {
613 sprintf(name
,"%s:p=|%s|,str=|%s|,sp=|%s|",getClassName(),fCPat
,fCStr
, fExpect
.data());
618 virtual UNumberFormat
* initFmt() {
619 DecimalFormat
*d
= new DecimalFormat(setupStatus
);
621 d
->applyPattern(fPat
, pe
, setupStatus
);
622 return (UNumberFormat
*) d
;
624 virtual const char *getClassName() {
625 return "NumFmtStringPieceTest";
628 NumFmtStringPieceTest(const char *pat
, const char *num
, const StringPiece
& expect
, const char *FILE, int LINE
)
629 : HowExpensiveTest("(n/a)",FILE, LINE
),
632 fPat(pat
, -1, US_INV
),
633 fString(num
,-1,US_INV
),
634 fStr(fString
.getTerminatedBuffer()),
635 fLen(u_strlen(fStr
)),
646 if(U_SUCCESS(setupStatus
)) {
648 ((const DecimalFormat
*)fFmt
)->format(fExpect
, buf
, NULL
, setupStatus
);
649 if(!U_SUCCESS(setupStatus
)
653 u_strToUTF8(strBuf
,200,NULL
,buf
.getTerminatedBuffer(),buf
.length()+1,&setupStatus
);
654 printf("%s:%d: warmup() %s got %s (len %d) expected %s (len %d), err %s\n",
655 fFile
,fLine
,getName(),strBuf
,buf
.length(),fCStr
,fLen
, u_errorName(setupStatus
));
656 setupStatus
= U_INTERNAL_PROGRAM_ERROR
;
667 if(U_SUCCESS(setupStatus
)) {
668 for(i
=0;i
<U_LOTS_OF_TIMES
;i
++){
670 ((const DecimalFormat
*)fFmt
)->format(fExpect
, buf
, NULL
, setupStatus
);
675 virtual ~NumFmtStringPieceTest(){}
678 #define DO_NumFmtStringPieceTest(p,n,x) { NumFmtStringPieceTest t(p,n,x,__FILE__,__LINE__); runTestOn(t); }
680 // TODO: move, scope.
681 static UChar pattern
[] = { 0x23 }; // '#'
682 static UChar strdot
[] = { '2', '.', '0', 0 };
683 static UChar strspc
[] = { '2', ' ', 0 };
684 static UChar strgrp
[] = {'2',',','2','2','2', 0 };
685 static UChar strbeng
[] = {0x09E8,0x09E8,0x09E8,0x09E8, 0 };
687 UNumberFormat
*NumParseTest_fmt
;
690 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
);})
692 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
);})
693 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
);})
694 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
);})
696 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
);})
698 UDateFormat
*DateFormatTest_fmt
= NULL
;
699 UDate sometime
= 100000000.0;
701 const int32_t onekbuf_len
= sizeof(onekbuf
)/sizeof(onekbuf
[0]);
704 QuickTest(DateFormatTestBasic
, \
706 DateFormatTest_fmt
= udat_open(UDAT_DEFAULT
, UDAT_DEFAULT
, NULL
, NULL
, -1, NULL
, -1, &setupStatus
); \
710 for(i
=0;i
<U_LOTS_OF_TIMES
;i
++) \
712 udat_format(DateFormatTest_fmt
, sometime
, onekbuf
, onekbuf_len
, NULL
, &setupStatus
); \
717 udat_close(DateFormatTest_fmt
); \
722 QuickTest(NullTest
,{},{int j
=U_LOTS_OF_TIMES
;while(--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
); return j
;} return U_LOTS_OF_TIMES
;},{})
730 OpenCloseTest(pattern
,unum
,open
,{},(UNUM_PATTERN_DECIMAL
,pattern
,1,TEST_LOCALE
,0,&setupStatus
),{})
731 OpenCloseTest(default,unum
,open
,{},(UNUM_DEFAULT
,NULL
,-1,TEST_LOCALE
,0,&setupStatus
),{})
732 #if !UCONFIG_NO_CONVERSION
733 #include "unicode/ucnv.h"
734 OpenCloseTest(gb18030
,ucnv
,open
,{},("gb18030",&setupStatus
),{})
736 #include "unicode/ures.h"
737 OpenCloseTest(root
,ures
,open
,{},(NULL
,"root",&setupStatus
),{})
755 #ifndef SKIP_DATEFMT_TESTS
757 DateFormatTestBasic t
;
762 #ifndef SKIP_NUMPARSE_TESTS
766 DO_NumTest("#","0",0.0);
767 DO_NumTest("#","2.0",2.0);
768 DO_NumTest("#","2 ",2);
769 DO_NumTest("#","-2 ",-2);
770 DO_NumTest("+#","+2",2);
771 DO_NumTest("#,###.0","2222.0",2222.0);
772 DO_NumTest("#.0","1.000000000000000000000000000000000000000000000000000000000000000000000000000000",1.0);
773 DO_NumTest("#","123456",123456);
776 #ifdef HAVE_UNUM_MAYBE
777 DO_AttrNumTest("#","0",0.0,UNUM_PARSE_ALL_INPUT
,UNUM_YES
);
778 DO_AttrNumTest("#","0",0.0,UNUM_PARSE_ALL_INPUT
,UNUM_NO
);
779 DO_AttrNumTest("#","0",0.0,UNUM_PARSE_ALL_INPUT
,UNUM_MAYBE
);
780 DO_TripleNumTest("#","2.0",2.0);
781 DO_AttrNumTest("#.0","1.000000000000000000000000000000000000000000000000000000000000000000000000000000",1.0,UNUM_PARSE_ALL_INPUT
,UNUM_NO
);
785 // { NumParseTestgrp t; runTestOn(t); }
786 { NumParseTestbeng t
; runTestOn(t
); }
791 #ifndef SKIP_NUMFORMAT_TESTS
795 DO_NumFmtInt64Test("0000","0001",1);
796 DO_NumFmtInt64Test("0000","0000",0);
797 StringPiece
sp3456("3456");
798 DO_NumFmtStringPieceTest("0000","3456",sp3456
);
799 DO_NumFmtStringPieceTest("#","3456",sp3456
);
800 StringPiece
sp3("3");
801 DO_NumFmtStringPieceTest("0000","0003",sp3
);
802 DO_NumFmtStringPieceTest("#","3",sp3
);
803 StringPiece
spn3("-3");
804 DO_NumFmtStringPieceTest("0000","-0003",spn3
);
805 DO_NumFmtStringPieceTest("#","-3",spn3
);
806 StringPiece
spPI("123.456");
807 DO_NumFmtStringPieceTest("#.0000","123.4560",spPI
);
808 DO_NumFmtStringPieceTest("#.00","123.46",spPI
);
810 DO_NumFmtTest("#","0",0.0);
811 DO_NumFmtTest("#","12345",12345);
812 DO_NumFmtTest("#","-2",-2);
813 DO_NumFmtTest("+#","+2",2);
815 DO_NumFmtInt64Test("#","-682",-682);
816 DO_NumFmtInt64Test("#","0",0);
817 DO_NumFmtInt64Test("#","12345",12345);
818 DO_NumFmtInt64Test("#,###","12,345",12345);
819 DO_NumFmtInt64Test("#","1234",1234);
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);
836 DO_NumFmtInt64Test("#","-2",-2);
837 DO_NumFmtInt64Test("+#","+2",2);
840 #ifndef SKIP_NUM_OPEN_TEST
842 Test_unum_opendefault t
;
846 Test_unum_openpattern t
;
851 #endif /* skip numformat tests */
852 #if !UCONFIG_NO_CONVERSION
854 Test_ucnv_opengb18030 t
;
859 Test_ures_openroot t
;
864 fprintf(stderr
, "ERROR: no tests matched.\n");