/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2010, International Business Machines Corporation and
+ * Copyright (c) 1997-2013, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
char buffer[64]; // nos changed from 10 to 64
char danger = 'p'; // guard against overrunning the buffer (rtg)
-#ifdef U_WINDOWS
+#if defined(_MSC_VER)
sprintf(buffer, "%I64d", num);
#else
sprintf(buffer, "%lld", (long long)num);
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0
}; /* "0123456789ABCDEF" */
+ if (digits < 0) { // auto-digits
+ digits = 2;
+ uint32_t max = 0xff;
+ while (number > max) {
+ digits += 2;
+ max = (max << 8) | 0xff;
+ }
+ }
switch (digits)
{
case 8:
return target;
}
+UnicodeString
+IntlTest::toHex(uint32_t number, int32_t digits) {
+ UnicodeString result;
+ appendHex(number, digits, result);
+ return result;
+}
+
static inline UBool isPrintable(UChar32 c) {
return c <= 0x7E && (c >= 0x20 || c == 9 || c == 0xA || c == 0xD);
}
errorCount = 0;
dataErrorCount = 0;
verbose = FALSE;
+ no_time = FALSE;
no_err_msg = FALSE;
warn_on_missing_data = FALSE;
quick = FALSE;
return rval;
}
+UBool IntlTest::setNotime( UBool no_time )
+{
+ UBool rval = this->no_time;
+ this->no_time = no_time;
+ return rval;
+}
+
UBool IntlTest::setWarnOnMissingData( UBool warn_on_missing_dataVal )
{
UBool rval = this->warn_on_missing_data;
}
// call individual tests, to be overriden to call implementations
-void IntlTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* par )
+void IntlTest::runIndexedTest( int32_t /*index*/, UBool /*exec*/, const char* & /*name*/, char* /*par*/ )
{
// to be overriden by a method like:
/*
}
*/
this->errln("*** runIndexedTest needs to be overriden! ***");
- name = ""; exec = exec; index = index; par = par;
}
UDate timeStop = uprv_getRawUTCtime();
rval = TRUE; // at least one test has been called
char secs[256];
- sprintf(secs, "%f", (timeStop-timeStart)/1000.0);
+ if(!no_time) {
+ sprintf(secs, "%f", (timeStop-timeStart)/1000.0);
+ } else {
+ secs[0]=0;
+ }
strcpy(saveBaseLoc,name);
if (lastErrorCount == errorCount) {
sprintf( msg, " } OK: %s ", name );
- str_timeDelta(msg+strlen(msg),timeStop-timeStart);
+ if(!no_time) str_timeDelta(msg+strlen(msg),timeStop-timeStart);
lastTestFailed = FALSE;
}else{
sprintf(msg, " } ERRORS (%li) in %s", (long)(errorCount-lastErrorCount), name);
- str_timeDelta(msg+strlen(msg),timeStop-timeStart);
+ if(!no_time) str_timeDelta(msg+strlen(msg),timeStop-timeStart);
for(int i=0;i<LL_indentlevel;i++) {
errorList += " ";
UBool all = FALSE;
UBool verbose = FALSE;
UBool no_err_msg = FALSE;
+ UBool no_time = FALSE;
UBool quick = TRUE;
UBool name = FALSE;
UBool leaks = FALSE;
else if (strcmp("leaks", str) == 0 ||
strcmp("l", str) == 0)
leaks = TRUE;
+ else if (strcmp("notime", str) == 0 ||
+ strcmp("T", str) == 0)
+ no_time = TRUE;
else if (strcmp("x", str)==0) {
if(++i>=argc) {
printf("* Error: '-x' option requires an argument. usage: '-x outfile.xml'.\n");
"### \n"
"### Options are: verbose (v), all (a), noerrormsg (n), \n"
"### exhaustive (e), leaks (l), -x xmlfile.xml, prop:<propery>=<value>, \n"
+ "### notime (T), \n"
"### threads:<threadCount> (Mulithreading must first be \n"
"### enabled otherwise this will be ignored. \n"
"### The default thread count is 1.),\n"
major.setLeaks( leaks );
major.setThreadCount( threadCount );
major.setWarnOnMissingData( warnOnMissingData );
+ major.setNotime (no_time);
for (int32_t i = 0; i < nProps; i++) {
major.setProperty(props[i]);
}
fprintf(stdout, " No error messages (n) : %s\n", (no_err_msg? "On" : "Off"));
fprintf(stdout, " Exhaustive (e) : %s\n", (!quick? "On" : "Off"));
fprintf(stdout, " Leaks (l) : %s\n", (leaks? "On" : "Off"));
+ fprintf(stdout, " notime (T) : %s\n", (no_time? "On" : "Off"));
fprintf(stdout, " Warn on missing data (w) : %s\n", (warnOnMissingData? "On" : "Off"));
#if (ICU_USE_THREADS==0)
fprintf(stdout, " Threads : Disabled\n");
if (execCount <= 0) {
fprintf(stdout, "***** Not all called tests actually exist! *****\n");
}
- endTime = uprv_getRawUTCtime();
- diffTime = (int32_t)(endTime - startTime);
- printf("Elapsed Time: %02d:%02d:%02d.%03d\n",
- (int)((diffTime%U_MILLIS_PER_DAY)/U_MILLIS_PER_HOUR),
- (int)((diffTime%U_MILLIS_PER_HOUR)/U_MILLIS_PER_MINUTE),
- (int)((diffTime%U_MILLIS_PER_MINUTE)/U_MILLIS_PER_SECOND),
- (int)(diffTime%U_MILLIS_PER_SECOND));
+ if(!no_time) {
+ endTime = uprv_getRawUTCtime();
+ diffTime = (int32_t)(endTime - startTime);
+ printf("Elapsed Time: %02d:%02d:%02d.%03d\n",
+ (int)((diffTime%U_MILLIS_PER_DAY)/U_MILLIS_PER_HOUR),
+ (int)((diffTime%U_MILLIS_PER_HOUR)/U_MILLIS_PER_MINUTE),
+ (int)((diffTime%U_MILLIS_PER_MINUTE)/U_MILLIS_PER_SECOND),
+ (int)(diffTime%U_MILLIS_PER_SECOND));
+ }
if(ctest_xml_fini())
return 1;
const char* tdrelativepath;
#if defined (U_TOPBUILDDIR)
- tdrelativepath = "test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING;
+ tdrelativepath = "test" U_FILE_SEP_STRING "testdata" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING;
directory = U_TOPBUILDDIR;
#else
- tdrelativepath = ".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING;
+ tdrelativepath = ".." U_FILE_SEP_STRING "test" U_FILE_SEP_STRING "testdata" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING;
directory = pathToDataDirectory();
#endif
const char *IntlTest::getSourceTestData(UErrorCode& /*err*/) {
const char *srcDataDir = NULL;
#ifdef U_TOPSRCDIR
- srcDataDir = U_TOPSRCDIR U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING;
+ srcDataDir = U_TOPSRCDIR U_FILE_SEP_STRING"test" U_FILE_SEP_STRING "testdata" U_FILE_SEP_STRING;
#else
- srcDataDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING;
- FILE *f = fopen(".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"rbbitst.txt", "r");
+ srcDataDir = ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "test" U_FILE_SEP_STRING "testdata" U_FILE_SEP_STRING;
+ FILE *f = fopen(".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "test" U_FILE_SEP_STRING "testdata" U_FILE_SEP_STRING "rbbitst.txt", "r");
if (f) {
/* We're in icu/source/test/intltest/ */
fclose(f);
}
else {
/* We're in icu/source/test/intltest/Platform/(Debug|Release) */
- srcDataDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING;
+ srcDataDir = ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "test" U_FILE_SEP_STRING "testdata"U_FILE_SEP_STRING;
}
#endif
return srcDataDir;
}
else {
/* __FILE__ on MSVC7 does not contain the directory */
- FILE *file = fopen(".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "Makefile.in", "r");
+ FILE *file = fopen(".." U_FILE_SEP_STRING ".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "Makefile.in", "r");
if (file) {
fclose(file);
- fgDataDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING;
+ fgDataDir = ".." U_FILE_SEP_STRING ".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING;
}
else {
- fgDataDir = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING;
+ fgDataDir = ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING ".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING;
}
}
}
#define VERBOSE_ASSERTIONS
-UBool IntlTest::assertTrue(const char* message, UBool condition, UBool quiet, UBool possibleDataError) {
- if (!condition) {
- if (possibleDataError) {
- dataerrln("FAIL: assertTrue() failed: %s", message);
- } else {
- errln("FAIL: assertTrue() failed: %s", message);
+UBool IntlTest::assertTrue(const char* message, UBool condition, UBool quiet, UBool possibleDataError, const char *file, int line) {
+ if (file != NULL) {
+ if (!condition) {
+ if (possibleDataError) {
+ dataerrln("%s:%d: FAIL: assertTrue() failed: %s", file, line, message);
+ } else {
+ errln("%s:%d: FAIL: assertTrue() failed: %s", file, line, message);
+ }
+ } else if (!quiet) {
+ logln("%s:%d: Ok: %s", file, line, message);
}
- } else if (!quiet) {
- logln("Ok: %s", message);
+ } else {
+ if (!condition) {
+ if (possibleDataError) {
+ dataerrln("FAIL: assertTrue() failed: %s", message);
+ } else {
+ errln("FAIL: assertTrue() failed: %s", message);
+ }
+ } else if (!quiet) {
+ logln("Ok: %s", message);
+ }
+
}
return condition;
}
return TRUE;
}
+UBool IntlTest::assertEquals(const char* message,
+ int32_t expected,
+ int32_t actual) {
+ if (expected != actual) {
+ errln((UnicodeString)"FAIL: " + message + "; got " +
+ actual + "=0x" + toHex(actual) +
+ "; expected " + expected + "=0x" + toHex(expected));
+ return FALSE;
+ }
+#ifdef VERBOSE_ASSERTIONS
+ else {
+ logln((UnicodeString)"Ok: " + message + "; got " + actual + "=0x" + toHex(actual));
+ }
+#endif
+ return TRUE;
+}
+
#if !UCONFIG_NO_FORMATTING
UBool IntlTest::assertEquals(const char* message,
const Formattable& expected,
// release
//--------------------------------------------------------------------
-UBool IntlTest::isICUVersionAtLeast(const UVersionInfo x) {
- UVersionInfo v;
- u_getVersion(v);
- return (uprv_memcmp(v, x, U_MAX_VERSION_LENGTH) >= 0);
+UBool IntlTest::isICUVersionBefore(int major, int minor, int milli) {
+ UVersionInfo iv;
+ UVersionInfo ov = { (uint8_t)major, (uint8_t)minor, (uint8_t)milli, 0 };
+ u_getVersion(iv);
+ return uprv_memcmp(iv, ov, U_MAX_VERSION_LENGTH) < 0;
}
#if !UCONFIG_NO_FORMATTING