16f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/*
26f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org **********************************************************************
36f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Copyright (c) 2011-2012,International Business Machines
46f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Corporation and others.  All Rights Reserved.
56f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org **********************************************************************
66f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
76f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#include <stdio.h>
86f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#include <string.h>
96f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#include "sieve.h"
116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#include "unicode/utimer.h"
126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#include "udbgutil.h"
136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#include "unicode/ustring.h"
146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#include "unicode/decimfmt.h"
156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#include "unicode/udat.h"
166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#if U_PLATFORM_IMPLEMENTS_POSIX
186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#include <unistd.h>
196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgstatic void usage(const char *prog) {
216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  fprintf(stderr, "Usage: %s [ -f outfile.xml ] [ -t 'TestName' ]\n", prog);
226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#endif
246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgvoid runTests(void);
266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#ifndef ITERATIONS
286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define ITERATIONS 5
296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#endif
306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgFILE *out = NULL;
336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgUErrorCode setupStatus = U_ZERO_ERROR;
346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgconst char *outName = NULL;
356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgint listmode = 0;
366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgconst char *testName = NULL;
376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgconst char *progname = NULL;
386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgint errflg = 0;
396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgint testhit = 0;
406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgint testMatch(const char *aName) {
426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  if(testName==NULL) return 1;
436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  int len = strlen(testName);
446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  if(testName[len-1]=='*') {
456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return strncmp(testName,aName,len-1);
466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  } else {
476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return strcmp(testName,aName);
486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
506f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
516f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgint main(int argc, char * const * argv){
526f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#if U_DEBUG
536f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  fprintf(stderr,"%s: warning: U_DEBUG is on.\n", argv[0]);
546f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#endif
556f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#if U_DEBUG
566f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  {
576f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    double m;
586f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    double s = uprv_getSieveTime(&m);
596f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    fprintf(stderr, "** Standard sieve time: %.9fs +/- %.9fs (%d iterations)\n", s,m, (int)U_LOTS_OF_TIMES);
606f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
616f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#endif
626f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
636f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#if U_PLATFORM_IMPLEMENTS_POSIX
646f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  int c;
656f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  extern int optind;
666f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  extern char *optarg;
676f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  while((c=getopt(argc,argv,"lf:t:")) != EOF) {
686f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    switch(c) {
696f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    case 'f':
706f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      outName = optarg;
716f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      break;
726f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    case 'l':
736f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      listmode++;
746f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      break;
756f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    case 't':
766f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      testName = optarg;
776f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      break;
786f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    case '?':
796f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      errflg++;
806f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
816f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(errflg) {
826f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      usage(progname);
836f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      return 0;
846f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
856f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
866f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  /* for ( ; optind < argc; optind++) {     ... argv[optind] } */
876f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#else
886f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  if(argc==2) {
896f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    outName = argv[1];
906f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  } else if(argc>2) {
916f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    fprintf(stderr, "Err: usage: %s [ output-file.xml ]\n", argv[0]);
926f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
936f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#endif
946f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
956f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(listmode && outName != NULL ) {
966f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fprintf(stderr, "Warning: no output when list mode\n");
976f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      outName=NULL;
986f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
996f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1006f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  if(outName != NULL) {
1016f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1026f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1036f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    out=fopen(outName,"w");
1046f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(out==NULL) {
1056f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fprintf(stderr,"Err: can't open %s for writing.\n", outName);
1066f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      return 1;
1076f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    } else {
1086f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fprintf(stderr, "# writing results to %s\n", outName);
1096f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
1106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    fprintf(out, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
1116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    fprintf(out, "<tests icu=\"%s\">\n", U_ICU_VERSION);
1126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    fprintf(out, "<!-- %s -->\n", U_COPYRIGHT_STRING);
1136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  } else {
1146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    fprintf(stderr, "# (no output)\n");
1156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
1166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  if(listmode && testName!=NULL) {
1186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    fprintf(stderr, "ERR: no -l mode when specific test with -t\n");
1196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    usage(progname);
1206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return 1;
1216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
1226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  runTests();
1256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  if(out!=NULL) {
1286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#ifndef SKIP_INFO
1296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    udbg_writeIcuInfo(out);
1306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#endif
1316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    fprintf(out, "</tests>\n");
1326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    fclose(out);
1336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
1346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  if(U_FAILURE(setupStatus)) {
1366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    fprintf(stderr, "Error in tests: %s\n", u_errorName(setupStatus));
1376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return 1;
1386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
1396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  return 0;
1416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
1426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgclass HowExpensiveTest {
1446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgpublic:
1456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual ~HowExpensiveTest(){}
1466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgprotected:
1476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  HowExpensiveTest(const char *name, const char *file, int32_t line) : fName(name), fFile(file), fLine(line) {}
1486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgprotected:
1496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  /**
1506f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org   * @return number of iterations
1516f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org   */
1526f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual int32_t run() = 0;
1536f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual void warmup() {  run(); }
1546f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgpublic:
1556f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual const char *getName() { return fName; }
1566f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgpublic:
1576f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual int32_t runTest(double *subTime) {
1586f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    UTimer a,b;
1596f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    utimer_getTime(&a);
1606f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    int32_t iter = run();
1616f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    utimer_getTime(&b);
1626f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    *subTime = utimer_getDeltaSeconds(&a,&b);
1636f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return iter;
1646f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
1656f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1666f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual int32_t runTests(double *subTime, double *marginOfError) {
1676f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    warmup(); /* warmup */
1686f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    double times[ITERATIONS];
1696f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    int subIterations = 0;
1706f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    for(int i=0;i<ITERATIONS;i++) {
1716f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      subIterations = runTest(&times[i]);
1726f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#if U_DEBUG
1736f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fprintf(stderr, "trial: %d/%d = %.9fs\n", i, ITERATIONS,times[i]);
1746f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fflush(stderr);
1756f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#endif
1766f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
1776f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    uint32_t iterations = ITERATIONS;
1786f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    *subTime = uprv_getMeanTime(times,&iterations,marginOfError);
1796f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return subIterations;
1806f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
1816f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgpublic:
1826f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  const char *fName;
1836f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  const char *fFile;
1846f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  int32_t fLine;
1856f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  int32_t fIterations;
1866f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org};
1876f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1886f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgvoid runTestOn(HowExpensiveTest &t) {
1896f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  if(U_FAILURE(setupStatus)) return; // silently
1906f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  const char *tn = t.getName();
1916f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  if(testName!=NULL && testMatch(tn)) return; // skipped.
1926f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  if(listmode) {
1936f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    fprintf(stderr, "%s:%d:\t%s\n", t.fFile, t.fLine, t.getName());
1946f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    testhit++;
1956f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return;
1966f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  } else {
1976f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    fprintf(stderr, "%s:%d: Running: %s\n", t.fFile, t.fLine, t.getName());
1986f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    testhit++;
1996f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
2006f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  double sieveTime = uprv_getSieveTime(NULL);
2016f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  double st;
2026f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  double me;
2036f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2046f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  fflush(stdout);
2056f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  fflush(stderr);
2066f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  int32_t iter = t.runTests(&st,&me);
2076f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  if(U_FAILURE(setupStatus)) {
2086f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    fprintf(stderr, "Error in tests: %s\n", u_errorName(setupStatus));
2096f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return;
2106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
2116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  fflush(stdout);
2126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  fflush(stderr);
2136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  double stn = st/sieveTime;
2156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  printf("%s\t%.9f\t%.9f +/- %.9f,  @ %d iter\n", t.getName(),stn,st,me,iter);
2176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  if(out!=NULL) {
2196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    fprintf(out, "   <test name=\"%s\" standardizedTime=\"%f\" realDuration=\"%f\" marginOfError=\"%f\" iterations=\"%d\" />\n",
2206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            tn,stn,st,me,iter);
2216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    fflush(out);
2226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
2236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
2246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/* ------------------- test code here --------------------- */
2266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgclass SieveTest : public HowExpensiveTest {
2286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgpublic:
2296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual ~SieveTest(){}
2306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  SieveTest():HowExpensiveTest("SieveTest",__FILE__,__LINE__){}
2316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual int32_t run(){return 0;} // dummy
2326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  int32_t runTest(double *subTime) {
2336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    *subTime = uprv_getSieveTime(NULL);
2346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return U_LOTS_OF_TIMES;
2356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
2366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual int32_t runTests(double *subTime, double *marginOfError) {
2376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    *subTime = uprv_getSieveTime(marginOfError);
2386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return U_LOTS_OF_TIMES;
2396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
2406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org};
2416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/* ------- NumParseTest ------------- */
2446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#include "unicode/unum.h"
2456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/* open and close tests */
2466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define OCName(svc,ub,testn,suffix,n) testn ## svc ## ub ## suffix ## n
2476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define OCStr(svc,ub,suffix,n) "Test_" # svc # ub # suffix # n
2486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define OCRun(svc,ub,suffix) svc ## ub ## suffix
2496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org// TODO: run away screaming
2506f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#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 };
2516f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define QuickTest(n,c,r,d)  class n : public HowExpensiveTest { public: n():HowExpensiveTest(#n,__FILE__,__LINE__) c int32_t run() r virtual ~n () d };
2526f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2536f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgclass NumTest : public HowExpensiveTest {
2546f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgprivate:
2556f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  double fExpect;
2566f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  UNumberFormat *fFmt;
2576f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  UnicodeString fPat;
2586f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  UnicodeString fString;
2596f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  const UChar *fStr;
2606f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  int32_t fLen;
2616f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  const char *fFile;
2626f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  int fLine;
2636f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  const char *fCPat;
2646f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  const char *fCStr;
2656f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  char name[100];
2666f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgpublic:
2676f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual const char *getName() {
2686f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(name[0]==0) {
2696f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      sprintf(name,"%s:p=|%s|,str=|%s|",getClassName(),fCPat,fCStr);
2706f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
2716f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return name;
2726f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
2736f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgprotected:
2746f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual UNumberFormat* initFmt() {
2756f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return unum_open(UNUM_PATTERN_DECIMAL, fPat.getTerminatedBuffer(), -1, "en_US", 0, &setupStatus);
2766f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
2776f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual const char *getClassName() {
2786f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return "NumTest";
2796f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
2806f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgpublic:
2816f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  NumTest(const char *pat, const char *num, double expect, const char *FILE, int LINE)
2826f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    : HowExpensiveTest("(n/a)",FILE, LINE),
2836f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fExpect(expect),
2846f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fFmt(0),
2856f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fPat(pat, -1, US_INV),
2866f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fString(num,-1,US_INV),
2876f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fStr(fString.getTerminatedBuffer()),
2886f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fLen(u_strlen(fStr)),
2896f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fFile(FILE),
2906f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fLine(LINE),
2916f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fCPat(pat),
2926f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fCStr(num)
2936f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  {
2946f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    name[0]=0;
2956f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
2966f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  void warmup() {
2976f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    fFmt = initFmt();
2986f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(U_SUCCESS(setupStatus)) {
2996f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      double trial = unum_parseDouble(fFmt,fStr,fLen, NULL, &setupStatus);
3006f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      if(U_SUCCESS(setupStatus) && trial!=fExpect) {
3016f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        setupStatus = U_INTERNAL_PROGRAM_ERROR;
3026f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        printf("%s:%d: warmup() %s got %.8f expected %.8f\n",
3036f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org               fFile,fLine,getName(),trial,fExpect);
3046f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      }
3056f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
3066f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
3076f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  int32_t run() {
3086f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    double trial=0.0;
3096f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    int i;
3106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    for(i=0;i<U_LOTS_OF_TIMES;i++){
3116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      trial = unum_parse(fFmt,fStr,fLen, NULL, &setupStatus);
3126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
3136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return i;
3146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
3156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual ~NumTest(){}
3166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org};
3176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define DO_NumTest(p,n,x) { NumTest t(p,n,x,__FILE__,__LINE__); runTestOn(t); }
3196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgclass AttrNumTest : public NumTest
3226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org{
3236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgprivate:
3246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  UNumberFormatAttribute fAttr;
3256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  int32_t fAttrValue;
3266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  char name2[100];
3276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgprotected:
3286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual const char *getClassName() {
3296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    sprintf(name2,"AttrNumTest:%d=%d", fAttr,fAttrValue);
3306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return name2;
3316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
3326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgpublic:
3336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  AttrNumTest(const char *pat, const char *num, double expect, const char *FILE, int LINE, UNumberFormatAttribute attr, int32_t newValue)
3346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    : NumTest(pat,num,expect,FILE,LINE),
3356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fAttr(attr),
3366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fAttrValue(newValue)
3376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  {
3386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
3396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual UNumberFormat* initFmt() {
3406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    UNumberFormat *fmt = NumTest::initFmt();
3416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    unum_setAttribute(fmt, fAttr,fAttrValue);
3426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return fmt;
3436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
3446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org};
3456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define DO_AttrNumTest(p,n,x,a,v) { AttrNumTest t(p,n,x,__FILE__,__LINE__,a,v); runTestOn(t); }
3476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgclass NOXNumTest : public NumTest
3506f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org{
3516f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgprivate:
3526f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  UNumberFormatAttribute fAttr;
3536f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  int32_t fAttrValue;
3546f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  char name2[100];
3556f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgprotected:
3566f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual const char *getClassName() {
3576f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    sprintf(name2,"NOXNumTest:%d=%d", fAttr,fAttrValue);
3586f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return name2;
3596f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
3606f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgpublic:
3616f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  NOXNumTest(const char *pat, const char *num, double expect, const char *FILE, int LINE /*, UNumberFormatAttribute attr, int32_t newValue */)
3626f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    : NumTest(pat,num,expect,FILE,LINE) /* ,
3636f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fAttr(attr),
3646f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fAttrValue(newValue) */
3656f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  {
3666f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
3676f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual UNumberFormat* initFmt() {
3686f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    UNumberFormat *fmt = NumTest::initFmt();
3696f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    //unum_setAttribute(fmt, fAttr,fAttrValue);
3706f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return fmt;
3716f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
3726f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org};
3736f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3746f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define DO_NOXNumTest(p,n,x) { NOXNumTest t(p,n,x,__FILE__,__LINE__); runTestOn(t); }
3756f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3766f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define DO_TripleNumTest(p,n,x) DO_AttrNumTest(p,n,x,UNUM_PARSE_ALL_INPUT,UNUM_YES) \
3776f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                                DO_AttrNumTest(p,n,x,UNUM_PARSE_ALL_INPUT,UNUM_NO) \
3786f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org                                DO_AttrNumTest(p,n,x,UNUM_PARSE_ALL_INPUT,UNUM_MAYBE)
3796f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3806f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3816f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgclass NumFmtTest : public HowExpensiveTest {
3826f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgprivate:
3836f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  double fExpect;
3846f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  UNumberFormat *fFmt;
3856f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  UnicodeString fPat;
3866f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  UnicodeString fString;
3876f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  const UChar *fStr;
3886f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  int32_t fLen;
3896f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  const char *fFile;
3906f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  int fLine;
3916f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  const char *fCPat;
3926f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  const char *fCStr;
3936f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  char name[100];
3946f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgpublic:
3956f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual const char *getName() {
3966f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(name[0]==0) {
3976f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      sprintf(name,"%s:p=|%s|,str=|%s|",getClassName(),fCPat,fCStr);
3986f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
3996f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return name;
4006f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
4016f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgprotected:
4026f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual UNumberFormat* initFmt() {
4036f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return unum_open(UNUM_PATTERN_DECIMAL, fPat.getTerminatedBuffer(), -1, "en_US", 0, &setupStatus);
4046f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
4056f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual const char *getClassName() {
4066f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return "NumFmtTest";
4076f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
4086f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgpublic:
4096f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  NumFmtTest(const char *pat, const char *num, double expect, const char *FILE, int LINE)
4106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    : HowExpensiveTest("(n/a)",FILE, LINE),
4116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fExpect(expect),
4126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fFmt(0),
4136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fPat(pat, -1, US_INV),
4146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fString(num,-1,US_INV),
4156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fStr(fString.getTerminatedBuffer()),
4166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fLen(u_strlen(fStr)),
4176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fFile(FILE),
4186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fLine(LINE),
4196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fCPat(pat),
4206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fCStr(num)
4216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  {
4226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    name[0]=0;
4236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
4246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  void warmup() {
4256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    fFmt = initFmt();
4266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    UChar buf[100];
4276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(U_SUCCESS(setupStatus)) {
4286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      int32_t trial = unum_formatDouble(fFmt,fExpect, buf, 100, NULL, &setupStatus);
4296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      if(!U_SUCCESS(setupStatus)
4306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org         || trial!=fLen
4316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org         ||trial<=0
4326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org         || u_strncmp(fStr,buf,trial)  ) {
4336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        char strBuf[200];
4346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        u_strToUTF8(strBuf,200,NULL,buf,trial+1,&setupStatus);
4356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        printf("%s:%d: warmup() %s got %s expected %s, err %s\n",
4366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org               fFile,fLine,getName(),strBuf,fCStr, u_errorName(setupStatus));
4376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        setupStatus = U_INTERNAL_PROGRAM_ERROR;
4386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      }
4396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
4406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
4416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  int32_t run() {
4426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    int32_t trial;
4436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    int i;
4446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    UChar buf[100];
4456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(U_SUCCESS(setupStatus)) {
4466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      for(i=0;i<U_LOTS_OF_TIMES;i++){
4476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        trial = unum_formatDouble(fFmt,fExpect, buf, 100, NULL, &setupStatus);
4486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      }
4496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
4506f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return i;
4516f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
4526f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual ~NumFmtTest(){}
4536f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org};
4546f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
4556f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define DO_NumFmtTest(p,n,x) { NumFmtTest t(p,n,x,__FILE__,__LINE__); runTestOn(t); }
4566f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
4576f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
4586f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgclass NumFmtInt64Test : public HowExpensiveTest {
4596f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgprivate:
4606f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  int64_t fExpect;
4616f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  UNumberFormat *fFmt;
4626f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  UnicodeString fPat;
4636f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  UnicodeString fString;
4646f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  const UChar *fStr;
4656f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  int32_t fLen;
4666f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  const char *fFile;
4676f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  int fLine;
4686f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  const char *fCPat;
4696f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  const char *fCStr;
4706f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  char name[100];
4716f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgpublic:
4726f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual const char *getName() {
4736f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(name[0]==0) {
4746f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      sprintf(name,"%s:p=|%s|,str=|%s|",getClassName(),fCPat,fCStr);
4756f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
4766f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return name;
4776f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
4786f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgprotected:
4796f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual UNumberFormat* initFmt() {
4806f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return unum_open(UNUM_PATTERN_DECIMAL, fPat.getTerminatedBuffer(), -1, "en_US", 0, &setupStatus);
4816f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
4826f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual const char *getClassName() {
4836f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return "NumFmtInt64Test";
4846f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
4856f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgpublic:
4866f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  NumFmtInt64Test(const char *pat, const char *num, int64_t expect, const char *FILE, int LINE)
4876f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    : HowExpensiveTest("(n/a)",FILE, LINE),
4886f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fExpect(expect),
4896f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fFmt(0),
4906f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fPat(pat, -1, US_INV),
4916f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fString(num,-1,US_INV),
4926f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fStr(fString.getTerminatedBuffer()),
4936f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fLen(u_strlen(fStr)),
4946f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fFile(FILE),
4956f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fLine(LINE),
4966f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fCPat(pat),
4976f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fCStr(num)
4986f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  {
4996f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    name[0]=0;
5006f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
5016f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  void warmup() {
5026f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    fFmt = initFmt();
5036f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    UChar buf[100];
5046f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(U_SUCCESS(setupStatus)) {
5056f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      int32_t trial = unum_formatInt64(fFmt,fExpect, buf, 100, NULL, &setupStatus);
5066f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      if(!U_SUCCESS(setupStatus)
5076f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org         || trial!=fLen
5086f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org         ||trial<=0
5096f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org         || u_strncmp(fStr,buf,trial)  ) {
5106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        char strBuf[200];
5116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        u_strToUTF8(strBuf,200,NULL,buf,trial+1,&setupStatus);
5126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        printf("%s:%d: warmup() %s got %s (len %d) expected %s (len %d), err %s\n",
5136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org               fFile,fLine,getName(),strBuf,trial,fCStr,fLen, u_errorName(setupStatus));
5146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        setupStatus = U_INTERNAL_PROGRAM_ERROR;
5156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      }
5166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
5176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
5186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  int32_t run() {
5196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    int32_t trial;
5206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    int i;
5216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    UChar buf[100];
5226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(U_SUCCESS(setupStatus)) {
5236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      for(i=0;i<U_LOTS_OF_TIMES;i++){
5246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        trial = unum_formatInt64(fFmt,fExpect, buf, 100, NULL, &setupStatus);
5256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      }
5266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
5276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return i;
5286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
5296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual ~NumFmtInt64Test(){}
5306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org};
5316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
5326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define DO_NumFmtInt64Test(p,n,x) { NumFmtInt64Test t(p,n,x,__FILE__,__LINE__); runTestOn(t); }
5336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
5346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
5356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgclass NumFmtStringPieceTest : public HowExpensiveTest {
5366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgprivate:
5376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  const StringPiece &fExpect;
5386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  UNumberFormat *fFmt;
5396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  UnicodeString fPat;
5406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  UnicodeString fString;
5416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  const UChar *fStr;
5426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  int32_t fLen;
5436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  const char *fFile;
5446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  int fLine;
5456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  const char *fCPat;
5466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  const char *fCStr;
5476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  char name[100];
5486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgpublic:
5496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual const char *getName() {
5506f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(name[0]==0) {
5516f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      sprintf(name,"%s:p=|%s|,str=|%s|,sp=|%s|",getClassName(),fCPat,fCStr, fExpect.data());
5526f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
5536f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return name;
5546f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
5556f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgprotected:
5566f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual UNumberFormat* initFmt() {
5576f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DecimalFormat *d = new DecimalFormat(setupStatus);
5586f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    UParseError pe;
5596f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    d->applyPattern(fPat, pe, setupStatus);
5606f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return (UNumberFormat*) d;
5616f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
5626f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual const char *getClassName() {
5636f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return "NumFmtStringPieceTest";
5646f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
5656f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgpublic:
5666f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  NumFmtStringPieceTest(const char *pat, const char *num, const StringPiece& expect, const char *FILE, int LINE)
5676f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    : HowExpensiveTest("(n/a)",FILE, LINE),
5686f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fExpect(expect),
5696f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fFmt(0),
5706f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fPat(pat, -1, US_INV),
5716f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fString(num,-1,US_INV),
5726f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fStr(fString.getTerminatedBuffer()),
5736f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fLen(u_strlen(fStr)),
5746f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fFile(FILE),
5756f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fLine(LINE),
5766f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fCPat(pat),
5776f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      fCStr(num)
5786f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  {
5796f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    name[0]=0;
5806f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
5816f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  void warmup() {
5826f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    fFmt = initFmt();
5836f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    UnicodeString buf;
5846f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(U_SUCCESS(setupStatus)) {
5856f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      buf.remove();
5866f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      ((const DecimalFormat*)fFmt)->format(fExpect, buf, NULL, setupStatus);
5876f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      if(!U_SUCCESS(setupStatus)
5886f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org         || fString!=buf
5896f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org         ) {
5906f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        char strBuf[200];
5916f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        u_strToUTF8(strBuf,200,NULL,buf.getTerminatedBuffer(),buf.length()+1,&setupStatus);
5926f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        printf("%s:%d: warmup() %s got %s (len %d) expected %s (len %d), err %s\n",
5936f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org               fFile,fLine,getName(),strBuf,buf.length(),fCStr,fLen, u_errorName(setupStatus));
5946f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        setupStatus = U_INTERNAL_PROGRAM_ERROR;
5956f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      }
5966f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
5976f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
5986f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
5996f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  int32_t run() {
6006f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    int32_t trial;
6016f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    int i=0;
6026f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    UnicodeString buf;
6036f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    if(U_SUCCESS(setupStatus)) {
6046f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      for(i=0;i<U_LOTS_OF_TIMES;i++){
6056f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        buf.remove();
6066f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        ((const DecimalFormat*)fFmt)->format(fExpect, buf, NULL, setupStatus);
6076f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      }
6086f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
6096f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    return i;
6106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
6116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  virtual ~NumFmtStringPieceTest(){}
6126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org};
6136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#define DO_NumFmtStringPieceTest(p,n,x) { NumFmtStringPieceTest t(p,n,x,__FILE__,__LINE__); runTestOn(t); }
6156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org// TODO: move, scope.
6176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgstatic UChar pattern[] = { 0x23 }; // '#'
6186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgstatic UChar strdot[] = { '2', '.', '0', 0 };
6196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgstatic UChar strspc[] = { '2', ' ', 0 };
6206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgstatic UChar strgrp[] = {'2',',','2','2','2', 0 };
6216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgstatic UChar strbeng[] = {0x09E8,0x09E8,0x09E8,0x09E8, 0 };
6226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgUNumberFormat *NumParseTest_fmt;
6246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org// TODO: de-uglify.
6266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgQuickTest(NumParseTest,{    static UChar pattern[] = { 0x23 };    NumParseTest_fmt = 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_LOTS_OF_TIMES;i++) {      val=unum_parse(NumParseTest_fmt,str,1,NULL,&setupStatus);    }    return i;  },{unum_close(NumParseTest_fmt);})
6276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgQuickTest(NumParseTestdot,{    static UChar pattern[] = { 0x23 };    NumParseTest_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;  },{unum_close(NumParseTest_fmt);})
6296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgQuickTest(NumParseTestspc,{    static UChar pattern[] = { 0x23 };    NumParseTest_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,strspc,1,NULL,&setupStatus);    }    return i;  },{unum_close(NumParseTest_fmt);})
6306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgQuickTest(NumParseTestgrp,{    static UChar pattern[] = { 0x23 };    NumParseTest_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,strgrp,-1,NULL,&setupStatus);    }    return i;  },{unum_close(NumParseTest_fmt);})
6316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgQuickTest(NumParseTestbeng,{    static UChar pattern[] = { 0x23 };    NumParseTest_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,strbeng,-1,NULL,&setupStatus);    }    return i;  },{unum_close(NumParseTest_fmt);})
6336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgUDateFormat *DateFormatTest_fmt = NULL;
6356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgUDate sometime = 100000000.0;
6366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgUChar onekbuf[1024];
6376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgconst int32_t onekbuf_len = sizeof(onekbuf)/sizeof(onekbuf[0]);
6386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgQuickTest(DateFormatTestBasic, \
6416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org          { \
6426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            DateFormatTest_fmt = udat_open(UDAT_DEFAULT, UDAT_DEFAULT, NULL, NULL, -1, NULL, -1, &setupStatus); \
6436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org          }, \
6446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org          { \
6456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            int i; \
6466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            for(i=0;i<U_LOTS_OF_TIMES;i++)  \
6476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            { \
6486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org              udat_format(DateFormatTest_fmt, sometime, onekbuf, onekbuf_len, NULL, &setupStatus); \
6496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            } \
6506f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            return i; \
6516f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org          }, \
6526f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org          { \
6536f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            udat_close(DateFormatTest_fmt); \
6546f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org          } \
6556f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org      )
6566f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6576f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6586f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgQuickTest(NullTest,{},{int j=U_LOTS_OF_TIMES;while(--j);return U_LOTS_OF_TIMES;},{})
6596f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6606f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#if 0
6616f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#include <time.h>
6626f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6636f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgQuickTest(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;},{})
6646f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#endif
6656f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6666f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgOpenCloseTest(pattern,unum,open,{},(UNUM_PATTERN_DECIMAL,pattern,1,"en_US",0,&setupStatus),{})
6676f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgOpenCloseTest(default,unum,open,{},(UNUM_DEFAULT,NULL,-1,"en_US",0,&setupStatus),{})
6686f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#if !UCONFIG_NO_CONVERSION
6696f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#include "unicode/ucnv.h"
6706f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgOpenCloseTest(gb18030,ucnv,open,{},("gb18030",&setupStatus),{})
6716f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#endif
6726f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#include "unicode/ures.h"
6736f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgOpenCloseTest(root,ures,open,{},(NULL,"root",&setupStatus),{})
6746f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6756f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgvoid runTests() {
6766f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  {
6776f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    SieveTest t;
6786f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    runTestOn(t);
6796f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
6806f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#if 0
6816f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  {
6826f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    RandomTest t;
6836f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    runTestOn(t);
6846f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
6856f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#endif
6866f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  {
6876f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    NullTest t;
6886f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    runTestOn(t);
6896f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
6906f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6916f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#ifndef SKIP_DATEFMT_TESTS
6926f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  {
6936f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DateFormatTestBasic t;
6946f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    runTestOn(t);
6956f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
6966f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#endif
6976f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
6986f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#ifndef SKIP_NUMPARSE_TESTS
6996f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  {
7006f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    // parse tests
7016f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7026f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumTest("#","0",0.0);
7036f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumTest("#","2.0",2.0);
7046f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumTest("#","2 ",2);
7056f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumTest("#","-2 ",-2);
7066f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumTest("+#","+2",2);
7076f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumTest("#,###.0","2222.0",2222.0);
7086f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumTest("#.0","1.000000000000000000000000000000000000000000000000000000000000000000000000000000",1.0);
7096f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumTest("#","123456",123456);
7106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    // attr
7126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#ifdef HAVE_UNUM_MAYBE
7136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_AttrNumTest("#","0",0.0,UNUM_PARSE_ALL_INPUT,UNUM_YES);
7146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_AttrNumTest("#","0",0.0,UNUM_PARSE_ALL_INPUT,UNUM_NO);
7156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_AttrNumTest("#","0",0.0,UNUM_PARSE_ALL_INPUT,UNUM_MAYBE);
7166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_TripleNumTest("#","2.0",2.0);
7176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_AttrNumTest("#.0","1.000000000000000000000000000000000000000000000000000000000000000000000000000000",1.0,UNUM_PARSE_ALL_INPUT,UNUM_NO);
7186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#endif
7196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    //  {    NumParseTestgrp t;    runTestOn(t);  }
7226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    {    NumParseTestbeng t;    runTestOn(t);  }
7236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
7256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#endif
7266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#ifndef SKIP_NUMFORMAT_TESTS
7286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  // format tests
7296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  {
7306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumFmtInt64Test("0000","0001",1);
7326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumFmtInt64Test("0000","0000",0);
7336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    StringPiece sp3456("3456");
7346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumFmtStringPieceTest("0000","3456",sp3456);
7356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumFmtStringPieceTest("#","3456",sp3456);
7366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    StringPiece sp3("3");
7376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumFmtStringPieceTest("0000","0003",sp3);
7386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumFmtStringPieceTest("#","3",sp3);
7396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    StringPiece spn3("-3");
7406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumFmtStringPieceTest("0000","-0003",spn3);
7416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumFmtStringPieceTest("#","-3",spn3);
7426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    StringPiece spPI("123.456");
7436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumFmtStringPieceTest("#.0000","123.4560",spPI);
7446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumFmtStringPieceTest("#.00","123.46",spPI);
7456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumFmtTest("#","0",0.0);
7476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumFmtTest("#","12345",12345);
7486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumFmtTest("#","-2",-2);
7496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumFmtTest("+#","+2",2);
7506f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumFmtInt64Test("#","-682",-682);
7516f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumFmtInt64Test("#","0",0);
7526f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumFmtInt64Test("#","12345",12345);
7536f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumFmtInt64Test("#","1234",1234);
7546f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumFmtInt64Test("#","123",123);
7556f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumFmtInt64Test("#","-2",-2);
7566f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    DO_NumFmtInt64Test("+#","+2",2);
7576f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
7586f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7596f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#ifndef SKIP_NUM_OPEN_TEST
7606f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  {
7616f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    Test_unum_opendefault t;
7626f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    runTestOn(t);
7636f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
7646f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  {
7656f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    Test_unum_openpattern t;
7666f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    runTestOn(t);
7676f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
7686f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#endif
7696f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7706f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#endif /* skip numformat tests */
7716f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#if !UCONFIG_NO_CONVERSION
7726f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  {
7736f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    Test_ucnv_opengb18030 t;
7746f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    runTestOn(t);
7756f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
7766f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org#endif
7776f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  {
7786f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    Test_ures_openroot t;
7796f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    runTestOn(t);
7806f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
7816f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
7826f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  if(testhit==0) {
7836f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    fprintf(stderr, "ERROR: no tests matched.\n");
7846f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org  }
7856f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org}
786