2 **********************************************************************
3 * Copyright (c) 2011-2016,International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
12 #include "unicode/utimer.h"
14 #include "unicode/ustring.h"
15 #include "unicode/decimfmt.h"
16 #include "unicode/udat.h"
19 #if U_PLATFORM_IMPLEMENTS_POSIX
22 static void usage(const char *prog
) {
23 fprintf(stderr
, "Usage: %s [ -f outfile.xml ] [ -t 'TestName' ]\n", prog
);
34 #define TEST_LOCALE "en_US"
38 UErrorCode setupStatus
= U_ZERO_ERROR
;
39 const char *outName
= NULL
;
41 const char *testName
= NULL
;
42 const char *progname
= NULL
;
46 int testMatch(const char *aName
) {
47 if(testName
==NULL
) return 1;
48 int len
= strlen(testName
);
49 if(testName
[len
-1]=='*') {
50 return strncmp(testName
,aName
,len
-1);
52 return strcmp(testName
,aName
);
56 int main(int argc
, char * const * argv
){
58 fprintf(stderr
,"%s: warning: U_DEBUG is on.\n", argv
[0]);
63 double s
= uprv_getSieveTime(&m
);
64 fprintf(stderr
, "** Standard sieve time: %.9fs +/- %.9fs (%d iterations)\n", s
,m
, (int)U_LOTS_OF_TIMES
);
68 #if U_PLATFORM_IMPLEMENTS_POSIX
72 while((c
=getopt(argc
,argv
,"lf:t:")) != EOF
) {
91 /* for ( ; optind < argc; optind++) { ... argv[optind] } */
96 fprintf(stderr
, "Err: usage: %s [ output-file.xml ]\n", argv
[0]);
100 if(listmode
&& outName
!= NULL
) {
101 fprintf(stderr
, "Warning: no output when list mode\n");
105 if(outName
!= NULL
) {
108 out
=fopen(outName
,"w");
110 fprintf(stderr
,"Err: can't open %s for writing.\n", outName
);
113 fprintf(stderr
, "# writing results to %s\n", outName
);
115 fprintf(out
, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
116 fprintf(out
, "<tests icu=\"%s\">\n", U_ICU_VERSION
);
117 fprintf(out
, "<!-- %s -->\n", U_COPYRIGHT_STRING
);
119 fprintf(stderr
, "# (no output)\n");
122 if(listmode
&& testName
!=NULL
) {
123 fprintf(stderr
, "ERR: no -l mode when specific test with -t\n");
134 udbg_writeIcuInfo(out
);
136 fprintf(out
, "</tests>\n");
140 if(U_FAILURE(setupStatus
)) {
141 fprintf(stderr
, "Error in tests: %s\n", u_errorName(setupStatus
));
148 class HowExpensiveTest
{
150 virtual ~HowExpensiveTest(){}
152 HowExpensiveTest(const char *name
, const char *file
, int32_t line
) : fName(name
), fFile(file
), fLine(line
) {}
155 * @return number of iterations
157 virtual int32_t run() = 0;
158 virtual void warmup() { run(); }
160 virtual const char *getName() { return fName
; }
162 virtual int32_t runTest(double *subTime
) {
165 int32_t iter
= run();
167 *subTime
= utimer_getDeltaSeconds(&a
,&b
);
171 virtual int32_t runTests(double *subTime
, double *marginOfError
) {
172 warmup(); /* warmup */
173 double times
[ITERATIONS
];
174 int subIterations
= 0;
175 for(int i
=0;i
<ITERATIONS
;i
++) {
176 subIterations
= runTest(×
[i
]);
178 fprintf(stderr
, "trial: %d/%d = %.9fs\n", i
, ITERATIONS
,times
[i
]);
182 uint32_t iterations
= ITERATIONS
;
183 *subTime
= uprv_getMeanTime(times
,&iterations
,marginOfError
);
184 return subIterations
;
193 void runTestOn(HowExpensiveTest
&t
) {
194 if(U_FAILURE(setupStatus
)) return; // silently
195 const char *tn
= t
.getName();
196 if(testName
!=NULL
&& testMatch(tn
)) return; // skipped.
198 fprintf(stderr
, "%s:%d:\t%s\n", t
.fFile
, t
.fLine
, t
.getName());
202 fprintf(stderr
, "%s:%d: Running: %s\n", t
.fFile
, t
.fLine
, t
.getName());
205 double sieveTime
= uprv_getSieveTime(NULL
);
211 int32_t iter
= t
.runTests(&st
,&me
);
212 if(U_FAILURE(setupStatus
)) {
213 fprintf(stderr
, "Error in tests: %s\n", u_errorName(setupStatus
));
219 double stn
= st
/sieveTime
;
221 printf("%s\t%.9f\t%.9f +/- %.9f, @ %d iter\n", t
.getName(),stn
,st
,me
,iter
);
224 fprintf(out
, " <test name=\"%s\" standardizedTime=\"%f\" realDuration=\"%f\" marginOfError=\"%f\" iterations=\"%d\" />\n",
230 /* ------------------- test code here --------------------- */
232 class SieveTest
: public HowExpensiveTest
{
234 virtual ~SieveTest(){}
235 SieveTest():HowExpensiveTest("SieveTest",__FILE__
,__LINE__
){}
236 virtual int32_t run(){return 0;} // dummy
237 int32_t runTest(double *subTime
) {
238 *subTime
= uprv_getSieveTime(NULL
);
239 return U_LOTS_OF_TIMES
;
241 virtual int32_t runTests(double *subTime
, double *marginOfError
) {
242 *subTime
= uprv_getSieveTime(marginOfError
);
243 return U_LOTS_OF_TIMES
;
248 /* ------- NumParseTest ------------- */
249 #include "unicode/unum.h"
250 /* open and close tests */
251 #define OCName(svc,ub,testn,suffix,n) testn ## svc ## ub ## suffix ## n
252 #define OCStr(svc,ub,suffix,n) "Test_" # svc # ub # suffix # n
253 #define OCRun(svc,ub,suffix) svc ## ub ## suffix
254 // TODO: run away screaming
255 #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 };
256 #define QuickTest(n,c,r,d) class n : public HowExpensiveTest { public: n():HowExpensiveTest(#n,__FILE__,__LINE__) c int32_t run() r virtual ~n () d };
258 class NumTest
: public HowExpensiveTest
{
263 UnicodeString fString
;
272 virtual const char *getName() {
274 sprintf(name
,"%s:p=|%s|,str=|%s|",getClassName(),fCPat
,fCStr
);
279 virtual UNumberFormat
* initFmt() {
280 return unum_open(UNUM_PATTERN_DECIMAL
, fPat
.getTerminatedBuffer(), -1, TEST_LOCALE
, 0, &setupStatus
);
282 virtual const char *getClassName() {
286 NumTest(const char *pat
, const char *num
, double expect
, const char *FILE, int LINE
)
287 : HowExpensiveTest("(n/a)",FILE, LINE
),
290 fPat(pat
, -1, US_INV
),
291 fString(num
,-1,US_INV
),
292 fStr(fString
.getTerminatedBuffer()),
293 fLen(u_strlen(fStr
)),
303 if(U_SUCCESS(setupStatus
)) {
304 double trial
= unum_parseDouble(fFmt
,fStr
,fLen
, NULL
, &setupStatus
);
305 if(U_SUCCESS(setupStatus
) && trial
!=fExpect
) {
306 setupStatus
= U_INTERNAL_PROGRAM_ERROR
;
307 printf("%s:%d: warmup() %s got %.8f expected %.8f\n",
308 fFile
,fLine
,getName(),trial
,fExpect
);
315 for(i
=0;i
<U_LOTS_OF_TIMES
;i
++){
316 trial
= unum_parse(fFmt
,fStr
,fLen
, NULL
, &setupStatus
);
323 #define DO_NumTest(p,n,x) { NumTest t(p,n,x,__FILE__,__LINE__); runTestOn(t); }
326 class AttrNumTest
: public NumTest
329 UNumberFormatAttribute fAttr
;
333 virtual const char *getClassName() {
334 sprintf(name2
,"AttrNumTest:%d=%d", fAttr
,fAttrValue
);
338 AttrNumTest(const char *pat
, const char *num
, double expect
, const char *FILE, int LINE
, UNumberFormatAttribute attr
, int32_t newValue
)
339 : NumTest(pat
,num
,expect
,FILE,LINE
),
344 virtual UNumberFormat
* initFmt() {
345 UNumberFormat
*fmt
= NumTest::initFmt();
346 unum_setAttribute(fmt
, fAttr
,fAttrValue
);
351 #define DO_AttrNumTest(p,n,x,a,v) { AttrNumTest t(p,n,x,__FILE__,__LINE__,a,v); runTestOn(t); }
354 class NOXNumTest
: public NumTest
357 UNumberFormatAttribute fAttr
;
361 virtual const char *getClassName() {
362 sprintf(name2
,"NOXNumTest:%d=%d", fAttr
,fAttrValue
);
366 NOXNumTest(const char *pat
, const char *num
, double expect
, const char *FILE, int LINE
/*, UNumberFormatAttribute attr, int32_t newValue */)
367 : NumTest(pat
,num
,expect
,FILE,LINE
) /* ,
369 fAttrValue(newValue) */
372 virtual UNumberFormat
* initFmt() {
373 UNumberFormat
*fmt
= NumTest::initFmt();
374 //unum_setAttribute(fmt, fAttr,fAttrValue);
379 #define DO_NOXNumTest(p,n,x) { NOXNumTest t(p,n,x,__FILE__,__LINE__); runTestOn(t); }
381 #define DO_TripleNumTest(p,n,x) DO_AttrNumTest(p,n,x,UNUM_PARSE_ALL_INPUT,UNUM_YES) \
382 DO_AttrNumTest(p,n,x,UNUM_PARSE_ALL_INPUT,UNUM_NO) \
383 DO_AttrNumTest(p,n,x,UNUM_PARSE_ALL_INPUT,UNUM_MAYBE)
386 class NumFmtTest
: public HowExpensiveTest
{
391 UnicodeString fString
;
400 virtual const char *getName() {
402 sprintf(name
,"%s:p=|%s|,str=|%s|",getClassName(),fCPat
,fCStr
);
407 virtual UNumberFormat
* initFmt() {
408 return unum_open(UNUM_PATTERN_DECIMAL
, fPat
.getTerminatedBuffer(), -1, TEST_LOCALE
, 0, &setupStatus
);
410 virtual const char *getClassName() {
414 NumFmtTest(const char *pat
, const char *num
, double expect
, const char *FILE, int LINE
)
415 : HowExpensiveTest("(n/a)",FILE, LINE
),
418 fPat(pat
, -1, US_INV
),
419 fString(num
,-1,US_INV
),
420 fStr(fString
.getTerminatedBuffer()),
421 fLen(u_strlen(fStr
)),
432 if(U_SUCCESS(setupStatus
)) {
433 int32_t trial
= unum_formatDouble(fFmt
,fExpect
, buf
, 100, NULL
, &setupStatus
);
434 if(!U_SUCCESS(setupStatus
)
437 || u_strncmp(fStr
,buf
,trial
) ) {
439 u_strToUTF8(strBuf
,200,NULL
,buf
,trial
+1,&setupStatus
);
440 printf("%s:%d: warmup() %s got %s expected %s, err %s\n",
441 fFile
,fLine
,getName(),strBuf
,fCStr
, u_errorName(setupStatus
));
442 setupStatus
= U_INTERNAL_PROGRAM_ERROR
;
450 if(U_SUCCESS(setupStatus
)) {
451 for(i
=0;i
<U_LOTS_OF_TIMES
;i
++){
452 trial
= unum_formatDouble(fFmt
,fExpect
, buf
, 100, NULL
, &setupStatus
);
457 virtual ~NumFmtTest(){}
460 #define DO_NumFmtTest(p,n,x) { NumFmtTest t(p,n,x,__FILE__,__LINE__); runTestOn(t); }
462 class NumFmtInt64Test
: public HowExpensiveTest
{
476 UnicodeString fString
;
485 virtual const char *getName() {
487 sprintf(name
,"%s:p=|%s|,str=|%s|",getClassName(),fCPat
,fCStr
);
492 virtual UNumberFormat
* initFmt() {
495 return unum_open(UNUM_PATTERN_DECIMAL
, fPat
.getTerminatedBuffer(), -1, TEST_LOCALE
, 0, &setupStatus
);
498 UNumberFormat
*fmt
= unum_open(UNUM_DECIMAL
, NULL
, -1, TEST_LOCALE
, 0, &setupStatus
);
499 unum_applyPattern(fmt
, FALSE
, fPat
.getTerminatedBuffer(), -1, NULL
, &setupStatus
);
504 UNumberFormat
*fmt
= unum_open(UNUM_PATTERN_DECIMAL
, fPat
.getTerminatedBuffer(), -1, TEST_LOCALE
, 0, &setupStatus
);
505 unum_setAttribute(fmt
, UNUM_GROUPING_USED
, UNUM_NO
);
510 UNumberFormat
*fmt
= unum_open(UNUM_DECIMAL
, NULL
, -1, TEST_LOCALE
, 0, &setupStatus
);
511 unum_applyPattern(fmt
, FALSE
, fPat
.getTerminatedBuffer(), -1, NULL
, &setupStatus
);
512 unum_setAttribute(fmt
, UNUM_GROUPING_USED
, UNUM_NO
);
517 return unum_open(UNUM_DEFAULT
, NULL
, -1, TEST_LOCALE
, 0, &setupStatus
);
520 virtual const char *getClassName() {
522 case EMode::kDefault
:
523 return "NumFmtInt64Test (default)";
524 case EMode::kPattern
:
525 return "NumFmtInt64Test (pattern)";
526 case EMode::kApplyPattern
:
527 return "NumFmtInt64Test (applypattern)";
528 case EMode::kGroupOff
:
529 return "NumFmtInt64Test (pattern, group=off)";
530 case EMode::kApplyGroupOff
:
531 return "NumFmtInt64Test (applypattern, group=off)";
533 return "NumFmtInt64Test (? ? ?)";
537 NumFmtInt64Test(const char *pat
, const char *num
, int64_t expect
, const char *FILE, int LINE
, EMode mode
)
538 : HowExpensiveTest("(n/a)",FILE, LINE
),
542 fPat(pat
, -1, US_INV
),
543 fString(num
,-1,US_INV
),
544 fStr(fString
.getTerminatedBuffer()),
545 fLen(u_strlen(fStr
)),
556 if(U_SUCCESS(setupStatus
)) {
557 int32_t trial
= unum_formatInt64(fFmt
,fExpect
, buf
, 100, NULL
, &setupStatus
);
558 if(!U_SUCCESS(setupStatus
)
561 || u_strncmp(fStr
,buf
,trial
) ) {
563 u_strToUTF8(strBuf
,200,NULL
,buf
,trial
+1,&setupStatus
);
564 printf("%s:%d: warmup() %s got %s (len %d) expected %s (len %d), err %s\n",
565 fFile
,fLine
,getName(),strBuf
,trial
,fCStr
,fLen
, u_errorName(setupStatus
));
566 setupStatus
= U_INTERNAL_PROGRAM_ERROR
;
574 if(U_SUCCESS(setupStatus
)) {
575 for(i
=0;i
<U_LOTS_OF_TIMES
;i
++){
576 trial
= unum_formatInt64(fFmt
,fExpect
, buf
, 100, NULL
, &setupStatus
);
581 virtual ~NumFmtInt64Test(){}
585 * unum_open .. with pattern, == new DecimalFormat(pattern)
587 #define DO_NumFmtInt64Test(p,n,x) { NumFmtInt64Test t(p,n,x,__FILE__,__LINE__,NumFmtInt64Test::EMode::kPattern); runTestOn(t); }
589 * unum_open(UNUM_DECIMAL), then
591 #define DO_NumFmtInt64Test_apply(p,n,x) { NumFmtInt64Test t(p,n,x,__FILE__,__LINE__,NumFmtInt64Test::EMode::kApplyPattern); runTestOn(t); }
593 #define DO_NumFmtInt64Test_default(p,n,x) { NumFmtInt64Test t(p,n,x,__FILE__,__LINE__,NumFmtInt64Test::EMode::kDefault); runTestOn(t); }
594 #define DO_NumFmtInt64Test_gr0(p,n,x) { NumFmtInt64Test t(p,n,x,__FILE__,__LINE__,NumFmtInt64Test::EMode::kGroupOff); runTestOn(t); }
595 #define DO_NumFmtInt64Test_applygr0(p,n,x) { NumFmtInt64Test t(p,n,x,__FILE__,__LINE__,NumFmtInt64Test::EMode::kApplyGroupOff); runTestOn(t); }
598 class NumFmtStringPieceTest
: public HowExpensiveTest
{
600 const StringPiece
&fExpect
;
603 UnicodeString fString
;
612 virtual const char *getName() {
614 sprintf(name
,"%s:p=|%s|,str=|%s|,sp=|%s|",getClassName(),fCPat
,fCStr
, fExpect
.data());
619 virtual UNumberFormat
* initFmt() {
620 DecimalFormat
*d
= new DecimalFormat(setupStatus
);
622 d
->applyPattern(fPat
, pe
, setupStatus
);
623 return (UNumberFormat
*) d
;
625 virtual const char *getClassName() {
626 return "NumFmtStringPieceTest";
629 NumFmtStringPieceTest(const char *pat
, const char *num
, const StringPiece
& expect
, const char *FILE, int LINE
)
630 : HowExpensiveTest("(n/a)",FILE, LINE
),
633 fPat(pat
, -1, US_INV
),
634 fString(num
,-1,US_INV
),
635 fStr(fString
.getTerminatedBuffer()),
636 fLen(u_strlen(fStr
)),
647 if(U_SUCCESS(setupStatus
)) {
649 ((const DecimalFormat
*)fFmt
)->format(fExpect
, buf
, NULL
, setupStatus
);
650 if(!U_SUCCESS(setupStatus
)
654 u_strToUTF8(strBuf
,200,NULL
,buf
.getTerminatedBuffer(),buf
.length()+1,&setupStatus
);
655 printf("%s:%d: warmup() %s got %s (len %d) expected %s (len %d), err %s\n",
656 fFile
,fLine
,getName(),strBuf
,buf
.length(),fCStr
,fLen
, u_errorName(setupStatus
));
657 setupStatus
= U_INTERNAL_PROGRAM_ERROR
;
668 if(U_SUCCESS(setupStatus
)) {
669 for(i
=0;i
<U_LOTS_OF_TIMES
;i
++){
671 ((const DecimalFormat
*)fFmt
)->format(fExpect
, buf
, NULL
, setupStatus
);
676 virtual ~NumFmtStringPieceTest(){}
679 #define DO_NumFmtStringPieceTest(p,n,x) { NumFmtStringPieceTest t(p,n,x,__FILE__,__LINE__); runTestOn(t); }
681 // TODO: move, scope.
682 static UChar pattern
[] = { 0x23 }; // '#'
683 static UChar strdot
[] = { '2', '.', '0', 0 };
684 static UChar strspc
[] = { '2', ' ', 0 };
685 static UChar strgrp
[] = {'2',',','2','2','2', 0 };
686 static UChar strbeng
[] = {0x09E8,0x09E8,0x09E8,0x09E8, 0 };
688 UNumberFormat
*NumParseTest_fmt
;
691 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
);})
693 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
);})
694 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
);})
695 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
);})
697 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
);})
699 UDateFormat
*DateFormatTest_fmt
= NULL
;
700 UDate sometime
= 100000000.0;
702 const int32_t onekbuf_len
= UPRV_LENGTHOF(onekbuf
);
705 QuickTest(DateFormatTestBasic
, \
707 DateFormatTest_fmt
= udat_open(UDAT_DEFAULT
, UDAT_DEFAULT
, NULL
, NULL
, -1, NULL
, -1, &setupStatus
); \
711 for(i
=0;i
<U_LOTS_OF_TIMES
;i
++) \
713 udat_format(DateFormatTest_fmt
, sometime
, onekbuf
, onekbuf_len
, NULL
, &setupStatus
); \
718 udat_close(DateFormatTest_fmt
); \
723 QuickTest(NullTest
,{},{int j
=U_LOTS_OF_TIMES
;while(--j
);return U_LOTS_OF_TIMES
;},{})
728 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
;},{})
731 OpenCloseTest(pattern
,unum
,open
,{},(UNUM_PATTERN_DECIMAL
,pattern
,1,TEST_LOCALE
,0,&setupStatus
),{})
732 OpenCloseTest(default,unum
,open
,{},(UNUM_DEFAULT
,NULL
,-1,TEST_LOCALE
,0,&setupStatus
),{})
733 #if !UCONFIG_NO_CONVERSION
734 #include "unicode/ucnv.h"
735 OpenCloseTest(gb18030
,ucnv
,open
,{},("gb18030",&setupStatus
),{})
737 #include "unicode/ures.h"
738 OpenCloseTest(root
,ures
,open
,{},(NULL
,"root",&setupStatus
),{})
756 #ifndef SKIP_DATEFMT_TESTS
758 DateFormatTestBasic t
;
763 #ifndef SKIP_NUMPARSE_TESTS
767 DO_NumTest("#","0",0.0);
768 DO_NumTest("#","2.0",2.0);
769 DO_NumTest("#","2 ",2);
770 DO_NumTest("#","-2 ",-2);
771 DO_NumTest("+#","+2",2);
772 DO_NumTest("#,###.0","2222.0",2222.0);
773 DO_NumTest("#.0","1.000000000000000000000000000000000000000000000000000000000000000000000000000000",1.0);
774 DO_NumTest("#","123456",123456);
777 #ifdef HAVE_UNUM_MAYBE
778 DO_AttrNumTest("#","0",0.0,UNUM_PARSE_ALL_INPUT
,UNUM_YES
);
779 DO_AttrNumTest("#","0",0.0,UNUM_PARSE_ALL_INPUT
,UNUM_NO
);
780 DO_AttrNumTest("#","0",0.0,UNUM_PARSE_ALL_INPUT
,UNUM_MAYBE
);
781 DO_TripleNumTest("#","2.0",2.0);
782 DO_AttrNumTest("#.0","1.000000000000000000000000000000000000000000000000000000000000000000000000000000",1.0,UNUM_PARSE_ALL_INPUT
,UNUM_NO
);
786 // { NumParseTestgrp t; runTestOn(t); }
787 { NumParseTestbeng t
; runTestOn(t
); }
792 #ifndef SKIP_NUMFORMAT_TESTS
796 DO_NumFmtInt64Test("0000","0001",1);
797 DO_NumFmtInt64Test("0000","0000",0);
798 StringPiece
sp3456("3456");
799 DO_NumFmtStringPieceTest("0000","3456",sp3456
);
800 DO_NumFmtStringPieceTest("#","3456",sp3456
);
801 StringPiece
sp3("3");
802 DO_NumFmtStringPieceTest("0000","0003",sp3
);
803 DO_NumFmtStringPieceTest("#","3",sp3
);
804 StringPiece
spn3("-3");
805 DO_NumFmtStringPieceTest("0000","-0003",spn3
);
806 DO_NumFmtStringPieceTest("#","-3",spn3
);
807 StringPiece
spPI("123.456");
808 DO_NumFmtStringPieceTest("#.0000","123.4560",spPI
);
809 DO_NumFmtStringPieceTest("#.00","123.46",spPI
);
811 DO_NumFmtTest("#","0",0.0);
812 DO_NumFmtTest("#","12345",12345);
813 DO_NumFmtTest("#","-2",-2);
814 DO_NumFmtTest("+#","+2",2);
816 DO_NumFmtInt64Test("#","-682",-682);
817 DO_NumFmtInt64Test("#","0",0);
818 DO_NumFmtInt64Test("#","12345",12345);
819 DO_NumFmtInt64Test("#,###","12,345",12345);
820 DO_NumFmtInt64Test("#","1234",1234);
821 DO_NumFmtInt64Test("#","123",123);
822 DO_NumFmtInt64Test("#,###","123",123);
823 DO_NumFmtInt64Test_apply("#","123",123);
824 DO_NumFmtInt64Test_apply("#","12345",12345);
825 DO_NumFmtInt64Test_apply("#,###","123",123);
826 DO_NumFmtInt64Test_apply("#,###","12,345",12345);
827 DO_NumFmtInt64Test_default("","123",123);
828 DO_NumFmtInt64Test_default("","12,345",12345);
829 DO_NumFmtInt64Test_applygr0("#","123",123);
830 DO_NumFmtInt64Test_applygr0("#","12345",12345);
831 DO_NumFmtInt64Test_applygr0("#,###","123",123);
832 DO_NumFmtInt64Test_applygr0("#,###","12345",12345);
833 DO_NumFmtInt64Test_gr0("#","123",123);
834 DO_NumFmtInt64Test_gr0("#","12345",12345);
835 DO_NumFmtInt64Test_gr0("#,###","123",123);
836 DO_NumFmtInt64Test_gr0("#,###","12345",12345);
837 DO_NumFmtInt64Test("#","-2",-2);
838 DO_NumFmtInt64Test("+#","+2",2);
841 #ifndef SKIP_NUM_OPEN_TEST
843 Test_unum_opendefault t
;
847 Test_unum_openpattern t
;
852 #endif /* skip numformat tests */
853 #if !UCONFIG_NO_CONVERSION
855 Test_ucnv_opengb18030 t
;
860 Test_ures_openroot t
;
865 fprintf(stderr
, "ERROR: no tests matched.\n");