// ------------------------------------- void CalendarLimitTest::test(UDate millis, icu::Calendar* cal, icu::DateFormat* fmt) { static const UDate kDrift = 1e-10; UErrorCode exception = U_ZERO_ERROR; UnicodeString theDate; UErrorCode status = U_ZERO_ERROR; cal->setTime(millis, exception); if (U_SUCCESS(exception)) { fmt->format(millis, theDate); UDate dt = fmt->parse(theDate, status); // allow a small amount of error (drift) if(! withinErr(dt, millis, kDrift)) { errln("FAIL:round trip for large milli, got: %.1lf wanted: %.1lf. (delta %.2lf greater than %.2lf)", dt, millis, uprv_fabs(millis-dt), uprv_fabs(dt*kDrift)); logln(UnicodeString(" ") + theDate + " " + CalendarTest::calToStr(*cal)); } else { logln(UnicodeString("OK: got ") + dt + ", wanted " + millis); logln(UnicodeString(" ") + theDate); } } }
double NumberFormatRoundTripTest::proportionalError(const Formattable& a, const Formattable& b) { double aa,bb; if(isDouble(a)) aa = a.getDouble(); else aa = a.getLong(); if(isDouble(b)) bb = b.getDouble(); else bb = b.getLong(); double error = aa - bb; if(aa != 0 && bb != 0) error /= aa; return uprv_fabs(error); }
void AstroTest::TestSunriseTimes(void) { UErrorCode status = U_ZERO_ERROR; initAstro(status); ASSERT_OK(status); // logln("Sunrise/Sunset times for San Jose, California, USA"); // CalendarAstronomer *astro2 = new CalendarAstronomer(-121.55, 37.20); // TimeZone *tz = TimeZone::createTimeZone("America/Los_Angeles"); // We'll use a table generated by the UNSO website as our reference // From: http://aa.usno.navy.mil/ //-Location: W079 25, N43 40 //-Rise and Set for the Sun for 2001 //-Zone: 4h West of Greenwich int32_t USNO[] = { 6,59, 19,45, 6,57, 19,46, 6,56, 19,47, 6,54, 19,48, 6,52, 19,49, 6,50, 19,51, 6,48, 19,52, 6,47, 19,53, 6,45, 19,54, 6,43, 19,55, 6,42, 19,57, 6,40, 19,58, 6,38, 19,59, 6,36, 20, 0, 6,35, 20, 1, 6,33, 20, 3, 6,31, 20, 4, 6,30, 20, 5, 6,28, 20, 6, 6,27, 20, 7, 6,25, 20, 8, 6,23, 20,10, 6,22, 20,11, 6,20, 20,12, 6,19, 20,13, 6,17, 20,14, 6,16, 20,16, 6,14, 20,17, 6,13, 20,18, 6,11, 20,19, }; logln("Sunrise/Sunset times for Toronto, Canada"); // long = 79 25", lat = 43 40" CalendarAstronomer *astro3 = new CalendarAstronomer(-(79+25/60), 43+40/60); // As of ICU4J 2.8 the ICU4J time zones implement pass-through // to the underlying JDK. Because of variation in the // underlying JDKs, we have to use a fixed-offset // SimpleTimeZone to get consistent behavior between JDKs. // The offset we want is [-18000000, 3600000] (raw, dst). // [aliu 10/15/03] // TimeZone tz = TimeZone.getTimeZone("America/Montreal"); TimeZone *tz = new SimpleTimeZone(-18000000 + 3600000, "Montreal(FIXED)"); GregorianCalendar *cal = new GregorianCalendar(tz->clone(), Locale::getUS(), status); GregorianCalendar *cal2 = new GregorianCalendar(tz->clone(), Locale::getUS(), status); cal->clear(); cal->set(UCAL_YEAR, 2001); cal->set(UCAL_MONTH, UCAL_APRIL); cal->set(UCAL_DAY_OF_MONTH, 1); cal->set(UCAL_HOUR_OF_DAY, 12); // must be near local noon for getSunRiseSet to work DateFormat *df_t = DateFormat::createTimeInstance(DateFormat::MEDIUM,Locale::getUS()); DateFormat *df_d = DateFormat::createDateInstance(DateFormat::MEDIUM,Locale::getUS()); DateFormat *df_dt = DateFormat::createDateTimeInstance(DateFormat::MEDIUM, DateFormat::MEDIUM, Locale::getUS()); if(!df_t || !df_d || !df_dt) { dataerrln("couldn't create dateformats."); return; } df_t->adoptTimeZone(tz->clone()); df_d->adoptTimeZone(tz->clone()); df_dt->adoptTimeZone(tz->clone()); for (int32_t i=0; i < 30; i++) { logln("setDate\n"); astro3->setDate(cal->getTime(status)); logln("getRiseSet(TRUE)\n"); UDate sunrise = astro3->getSunRiseSet(TRUE); logln("getRiseSet(FALSE)\n"); UDate sunset = astro3->getSunRiseSet(FALSE); logln("end of getRiseSet\n"); cal2->setTime(cal->getTime(status), status); cal2->set(UCAL_SECOND, 0); cal2->set(UCAL_MILLISECOND, 0); cal2->set(UCAL_HOUR_OF_DAY, USNO[4*i+0]); cal2->set(UCAL_MINUTE, USNO[4*i+1]); UDate exprise = cal2->getTime(status); cal2->set(UCAL_HOUR_OF_DAY, USNO[4*i+2]); cal2->set(UCAL_MINUTE, USNO[4*i+3]); UDate expset = cal2->getTime(status); // Compute delta of what we got to the USNO data, in seconds int32_t deltarise = (int32_t)uprv_fabs((sunrise - exprise) / 1000); int32_t deltaset = (int32_t)uprv_fabs((sunset - expset) / 1000); // Allow a deviation of 0..MAX_DEV seconds // It would be nice to get down to 60 seconds, but at this // point that appears to be impossible without a redo of the // algorithm using something more advanced than Duffett-Smith. int32_t MAX_DEV = 180; UnicodeString s1, s2, s3, s4, s5; if (deltarise > MAX_DEV || deltaset > MAX_DEV) { if (deltarise > MAX_DEV) { errln("FAIL: (rise) " + df_d->format(cal->getTime(status),s1) + ", Sunrise: " + df_dt->format(sunrise, s2) + " (USNO " + df_t->format(exprise,s3) + " d=" + deltarise + "s)"); } else { logln(df_d->format(cal->getTime(status),s1) + ", Sunrise: " + df_dt->format(sunrise,s2) + " (USNO " + df_t->format(exprise,s3) + ")"); } s1.remove(); s2.remove(); s3.remove(); s4.remove(); s5.remove(); if (deltaset > MAX_DEV) { errln("FAIL: (set) " + df_d->format(cal->getTime(status),s1) + ", Sunset: " + df_dt->format(sunset,s2) + " (USNO " + df_t->format(expset,s3) + " d=" + deltaset + "s)"); } else { logln(df_d->format(cal->getTime(status),s1) + ", Sunset: " + df_dt->format(sunset,s2) + " (USNO " + df_t->format(expset,s3) + ")"); } } else { logln(df_d->format(cal->getTime(status),s1) + ", Sunrise: " + df_dt->format(sunrise,s2) + " (USNO " + df_t->format(exprise,s3) + ")" + ", Sunset: " + df_dt->format(sunset,s4) + " (USNO " + df_t->format(expset,s5) + ")"); } cal->add(UCAL_DATE, 1, status); } // CalendarAstronomer a = new CalendarAstronomer(-(71+5/60), 42+37/60); // cal.clear(); // cal.set(cal.YEAR, 1986); // cal.set(cal.MONTH, cal.MARCH); // cal.set(cal.DATE, 10); // cal.set(cal.YEAR, 1988); // cal.set(cal.MONTH, cal.JULY); // cal.set(cal.DATE, 27); // a.setDate(cal.getTime()); // long r = a.getSunRiseSet2(true); delete astro3; delete tz; delete cal; delete cal2; delete df_t; delete df_d; delete df_dt; closeAstro(status); ASSERT_OK(status); }
UBool CalendarLimitTest::withinErr(double a, double b, double err) { return ( uprv_fabs(a - b) < uprv_fabs(a * err) ); }
static void TestPUtilAPI(void){ double n1=0.0, y1=0.0, expn1, expy1; double value1 = 0.021; char *str=0; UBool isTrue=FALSE; log_verbose("Testing the API uprv_modf()\n"); y1 = uprv_modf(value1, &n1); expn1=0; expy1=0.021; if(y1 != expy1 || n1 != expn1){ log_err("Error in uprv_modf. Expected IntegralValue=%f, Got=%f, \n Expected FractionalValue=%f, Got=%f\n", expn1, n1, expy1, y1); } if(getTestOption(VERBOSITY_OPTION)){ log_verbose("[float] x = %f n = %f y = %f\n", value1, n1, y1); } log_verbose("Testing the API uprv_fmod()\n"); expn1=uprv_fmod(30.50, 15.00); doAssert(expn1, 0.5, "uprv_fmod(30.50, 15.00) failed."); log_verbose("Testing the API uprv_ceil()\n"); expn1=uprv_ceil(value1); doAssert(expn1, 1, "uprv_ceil(0.021) failed."); log_verbose("Testing the API uprv_floor()\n"); expn1=uprv_floor(value1); doAssert(expn1, 0, "uprv_floor(0.021) failed."); log_verbose("Testing the API uprv_fabs()\n"); expn1=uprv_fabs((2.02-1.345)); doAssert(expn1, 0.675, "uprv_fabs(2.02-1.345) failed."); log_verbose("Testing the API uprv_fmax()\n"); doAssert(uprv_fmax(2.4, 1.2), 2.4, "uprv_fmax(2.4, 1.2) failed."); log_verbose("Testing the API uprv_fmax() with x value= NaN\n"); expn1=uprv_fmax(uprv_getNaN(), 1.2); doAssert(expn1, uprv_getNaN(), "uprv_fmax(uprv_getNaN(), 1.2) failed. when one parameter is NaN"); log_verbose("Testing the API uprv_fmin()\n"); doAssert(uprv_fmin(2.4, 1.2), 1.2, "uprv_fmin(2.4, 1.2) failed."); log_verbose("Testing the API uprv_fmin() with x value= NaN\n"); expn1=uprv_fmin(uprv_getNaN(), 1.2); doAssert(expn1, uprv_getNaN(), "uprv_fmin(uprv_getNaN(), 1.2) failed. when one parameter is NaN"); log_verbose("Testing the API uprv_max()\n"); doAssert(uprv_max(4, 2), 4, "uprv_max(4, 2) failed."); log_verbose("Testing the API uprv_min()\n"); doAssert(uprv_min(-4, 2), -4, "uprv_min(-4, 2) failed."); log_verbose("Testing the API uprv_trunc()\n"); doAssert(uprv_trunc(12.3456), 12, "uprv_trunc(12.3456) failed."); doAssert(uprv_trunc(12.234E2), 1223, "uprv_trunc(12.234E2) failed."); doAssert(uprv_trunc(uprv_getNaN()), uprv_getNaN(), "uprv_trunc(uprv_getNaN()) failed. with parameter=NaN"); doAssert(uprv_trunc(uprv_getInfinity()), uprv_getInfinity(), "uprv_trunc(uprv_getInfinity()) failed. with parameter=Infinity"); log_verbose("Testing the API uprv_pow10()\n"); doAssert(uprv_pow10(4), 10000, "uprv_pow10(4) failed."); log_verbose("Testing the API uprv_isNegativeInfinity()\n"); isTrue=uprv_isNegativeInfinity(uprv_getInfinity() * -1); if(isTrue != TRUE){ log_err("ERROR: uprv_isNegativeInfinity failed.\n"); } log_verbose("Testing the API uprv_isPositiveInfinity()\n"); isTrue=uprv_isPositiveInfinity(uprv_getInfinity()); if(isTrue != TRUE){ log_err("ERROR: uprv_isPositiveInfinity failed.\n"); } log_verbose("Testing the API uprv_isInfinite()\n"); isTrue=uprv_isInfinite(uprv_getInfinity()); if(isTrue != TRUE){ log_err("ERROR: uprv_isInfinite failed.\n"); } #if 0 log_verbose("Testing the API uprv_digitsAfterDecimal()....\n"); doAssert(uprv_digitsAfterDecimal(value1), 3, "uprv_digitsAfterDecimal() failed."); doAssert(uprv_digitsAfterDecimal(1.2345E2), 2, "uprv_digitsAfterDecimal(1.2345E2) failed."); doAssert(uprv_digitsAfterDecimal(1.2345E-2), 6, "uprv_digitsAfterDecimal(1.2345E-2) failed."); doAssert(uprv_digitsAfterDecimal(1.2345E2), 2, "uprv_digitsAfterDecimal(1.2345E2) failed."); doAssert(uprv_digitsAfterDecimal(-1.2345E-20), 24, "uprv_digitsAfterDecimal(1.2345E-20) failed."); doAssert(uprv_digitsAfterDecimal(1.2345E20), 0, "uprv_digitsAfterDecimal(1.2345E20) failed."); doAssert(uprv_digitsAfterDecimal(-0.021), 3, "uprv_digitsAfterDecimal(-0.021) failed."); doAssert(uprv_digitsAfterDecimal(23.0), 0, "uprv_digitsAfterDecimal(23.0) failed."); doAssert(uprv_digitsAfterDecimal(0.022223333321), 9, "uprv_digitsAfterDecimal(0.022223333321) failed."); #endif log_verbose("Testing the API u_errorName()...\n"); str=(char*)u_errorName((UErrorCode)0); if(strcmp(str, "U_ZERO_ERROR") != 0){ log_err("ERROR: u_getVersion() failed. Expected: U_ZERO_ERROR Got=%s\n", str); } log_verbose("Testing the API u_errorName()...\n"); str=(char*)u_errorName((UErrorCode)-127); if(strcmp(str, "U_USING_DEFAULT_WARNING") != 0){ log_err("ERROR: u_getVersion() failed. Expected: U_USING_DEFAULT_WARNING Got=%s\n", str); } log_verbose("Testing the API u_errorName().. with BOGUS ERRORCODE...\n"); str=(char*)u_errorName((UErrorCode)200); if(strcmp(str, "[BOGUS UErrorCode]") != 0){ log_err("ERROR: u_getVersion() failed. Expected: [BOGUS UErrorCode] Got=%s\n", str); } { const char* dataDirectory; int32_t dataDirectoryLen; UChar *udataDir=0; UChar temp[100]; char *charvalue=0; log_verbose("Testing chars to UChars\n"); /* This cannot really work on a japanese system. u_uastrcpy will have different results than */ /* u_charsToUChars when there is a backslash in the string! */ /*dataDirectory=u_getDataDirectory();*/ dataDirectory="directory1"; /*no backslashes*/ dataDirectoryLen=(int32_t)strlen(dataDirectory); udataDir=(UChar*)malloc(sizeof(UChar) * (dataDirectoryLen + 1)); u_charsToUChars(dataDirectory, udataDir, (dataDirectoryLen + 1)); u_uastrcpy(temp, dataDirectory); if(u_strcmp(temp, udataDir) != 0){ log_err("ERROR: u_charsToUChars failed. Expected %s, Got %s\n", austrdup(temp), austrdup(udataDir)); } log_verbose("Testing UChars to chars\n"); charvalue=(char*)malloc(sizeof(char) * (u_strlen(udataDir) + 1)); u_UCharsToChars(udataDir, charvalue, (u_strlen(udataDir)+1)); if(strcmp(charvalue, dataDirectory) != 0){ log_err("ERROR: u_UCharsToChars failed. Expected %s, Got %s\n", charvalue, dataDirectory); } free(charvalue); free(udataDir); } log_verbose("Testing uprv_timezone()....\n"); { int32_t tzoffset = uprv_timezone(); log_verbose("Value returned from uprv_timezone = %d\n", tzoffset); if (tzoffset != 28800) { log_verbose("***** WARNING: If testing in the PST timezone, t_timezone should return 28800! *****"); } if ((tzoffset % 1800 != 0)) { log_info("Note: t_timezone offset of %ld (for %s : %s) is not a multiple of 30min.", tzoffset, uprv_tzname(0), uprv_tzname(1)); } /*tzoffset=uprv_getUTCtime();*/ } }
virtual double transformNumber(double number) const { return uprv_fabs(number); }
static void TestPUtilAPI(void){ double n1=0.0, y1=0.0, expn1, expy1; double value1 = 0.021; UVersionInfo versionArray = {0x01, 0x00, 0x02, 0x02}; char versionString[17]; /* xxx.xxx.xxx.xxx\0 */ char *str=0; UBool isTrue=FALSE; log_verbose("Testing the API uprv_modf()\n"); y1 = uprv_modf(value1, &n1); expn1=0; expy1=0.021; if(y1 != expy1 || n1 != expn1){ log_err("Error in uprv_modf. Expected IntegralValue=%f, Got=%f, \n Expected FractionalValue=%f, Got=%f\n", expn1, n1, expy1, y1); } if(VERBOSITY){ log_verbose("[float] x = %f n = %f y = %f\n", value1, n1, y1); } log_verbose("Testing the API uprv_fmod()\n"); expn1=uprv_fmod(30.50, 15.00); doAssert(expn1, 0.5, "uprv_fmod(30.50, 15.00) failed."); log_verbose("Testing the API uprv_ceil()\n"); expn1=uprv_ceil(value1); doAssert(expn1, 1, "uprv_ceil(0.021) failed."); log_verbose("Testing the API uprv_floor()\n"); expn1=uprv_floor(value1); doAssert(expn1, 0, "uprv_floor(0.021) failed."); log_verbose("Testing the API uprv_fabs()\n"); expn1=uprv_fabs((2.02-1.345)); doAssert(expn1, 0.675, "uprv_fabs(2.02-1.345) failed."); log_verbose("Testing the API uprv_fmax()\n"); doAssert(uprv_fmax(2.4, 1.2), 2.4, "uprv_fmax(2.4, 1.2) failed."); log_verbose("Testing the API uprv_fmax() with x value= NaN\n"); expn1=uprv_fmax(uprv_getNaN(), 1.2); doAssert(expn1, uprv_getNaN(), "uprv_fmax(uprv_getNaN(), 1.2) failed. when one parameter is NaN"); log_verbose("Testing the API uprv_fmin()\n"); doAssert(uprv_fmin(2.4, 1.2), 1.2, "uprv_fmin(2.4, 1.2) failed."); log_verbose("Testing the API uprv_fmin() with x value= NaN\n"); expn1=uprv_fmin(uprv_getNaN(), 1.2); doAssert(expn1, uprv_getNaN(), "uprv_fmin(uprv_getNaN(), 1.2) failed. when one parameter is NaN"); log_verbose("Testing the API uprv_max()\n"); doAssert(uprv_max(4, 2), 4, "uprv_max(4, 2) failed."); log_verbose("Testing the API uprv_min()\n"); doAssert(uprv_min(-4, 2), -4, "uprv_min(-4, 2) failed."); log_verbose("Testing the API uprv_trunc()\n"); doAssert(uprv_trunc(12.3456), 12, "uprv_trunc(12.3456) failed."); doAssert(uprv_trunc(12.234E2), 1223, "uprv_trunc(12.234E2) failed."); doAssert(uprv_trunc(uprv_getNaN()), uprv_getNaN(), "uprv_trunc(uprv_getNaN()) failed. with parameter=NaN"); doAssert(uprv_trunc(uprv_getInfinity()), uprv_getInfinity(), "uprv_trunc(uprv_getInfinity()) failed. with parameter=Infinity"); log_verbose("Testing the API uprv_pow10()\n"); doAssert(uprv_pow10(4), 10000, "uprv_pow10(4) failed."); log_verbose("Testing the API uprv_log10()\n"); doAssert(uprv_log10(3456), 3, "uprv_log10(3456) failed."); #ifdef OS390 doAssert(uprv_log10(1.0e55), 55, "uprv_log10(1.0e55) failed."); #else doAssert(uprv_log10(1.0e300), 300, "uprv_log10(1.0e300) failed."); #endif log_verbose("Testing the API uprv_isNegativeInfinity()\n"); isTrue=uprv_isNegativeInfinity(uprv_getInfinity() * -1); if(isTrue != TRUE){ log_err("ERROR: uprv_isNegativeInfinity failed.\n"); } log_verbose("Testing the API uprv_isPositiveInfinity()\n"); isTrue=uprv_isPositiveInfinity(uprv_getInfinity()); if(isTrue != TRUE){ log_err("ERROR: uprv_isPositiveInfinity failed.\n"); } log_verbose("Testing the API uprv_isInfinite()\n"); isTrue=uprv_isInfinite(uprv_getInfinity()); if(isTrue != TRUE){ log_err("ERROR: uprv_isInfinite failed.\n"); } #if 0 log_verbose("Testing the API uprv_digitsAfterDecimal()....\n"); doAssert(uprv_digitsAfterDecimal(value1), 3, "uprv_digitsAfterDecimal() failed."); doAssert(uprv_digitsAfterDecimal(1.2345E2), 2, "uprv_digitsAfterDecimal(1.2345E2) failed."); doAssert(uprv_digitsAfterDecimal(1.2345E-2), 6, "uprv_digitsAfterDecimal(1.2345E-2) failed."); doAssert(uprv_digitsAfterDecimal(1.2345E2), 2, "uprv_digitsAfterDecimal(1.2345E2) failed."); doAssert(uprv_digitsAfterDecimal(-1.2345E-20), 24, "uprv_digitsAfterDecimal(1.2345E-20) failed."); doAssert(uprv_digitsAfterDecimal(1.2345E20), 0, "uprv_digitsAfterDecimal(1.2345E20) failed."); doAssert(uprv_digitsAfterDecimal(-0.021), 3, "uprv_digitsAfterDecimal(-0.021) failed."); doAssert(uprv_digitsAfterDecimal(23.0), 0, "uprv_digitsAfterDecimal(23.0) failed."); doAssert(uprv_digitsAfterDecimal(0.022223333321), 9, "uprv_digitsAfterDecimal(0.022223333321) failed."); #endif log_verbose("Testing the API u_versionToString().....\n"); u_versionToString(versionArray, versionString); if(strcmp(versionString, "1.0.2.2") != 0){ log_err("ERROR: u_versionToString() failed. Expected: 1.0.2.2, Got=%s\n", versionString); } log_verbose("Testing the API u_versionToString().....with versionArray=NULL\n"); u_versionToString(NULL, versionString); if(strcmp(versionString, "") != 0){ log_err("ERROR: u_versionToString() failed. with versionArray=NULL. It should just return\n"); } log_verbose("Testing the API u_versionToString().....with versionArray=NULL\n"); u_versionToString(NULL, versionString); if(strcmp(versionString, "") != 0){ log_err("ERROR: u_versionToString() failed . It should just return\n"); } log_verbose("Testing the API u_versionToString().....with versionString=NULL\n"); u_versionToString(versionArray, NULL); if(strcmp(versionString, "") != 0){ log_err("ERROR: u_versionToString() failed. with versionArray=NULL It should just return\n"); } versionArray[0] = 0x0a; log_verbose("Testing the API u_versionToString().....\n"); u_versionToString(versionArray, versionString); if(strcmp(versionString, "10.0.2.2") != 0){ log_err("ERROR: u_versionToString() failed. Expected: 10.0.2.2, Got=%s\n", versionString); } versionArray[0] = 0xa0; u_versionToString(versionArray, versionString); if(strcmp(versionString, "160.0.2.2") != 0){ log_err("ERROR: u_versionToString() failed. Expected: 160.0.2.2, Got=%s\n", versionString); } versionArray[0] = 0xa0; versionArray[1] = 0xa0; u_versionToString(versionArray, versionString); if(strcmp(versionString, "160.160.2.2") != 0){ log_err("ERROR: u_versionToString() failed. Expected: 160.160.2.2, Got=%s\n", versionString); } versionArray[0] = 0x01; versionArray[1] = 0x0a; u_versionToString(versionArray, versionString); if(strcmp(versionString, "1.10.2.2") != 0){ log_err("ERROR: u_versionToString() failed. Expected: 160.160.2.2, Got=%s\n", versionString); } log_verbose("Testing the API u_versionFromString() ....\n"); u_versionFromString(versionArray, "1.3.5.6"); u_versionToString(versionArray, versionString); if(strcmp(versionString, "1.3.5.6") != 0){ log_err("ERROR: u_getVersion() failed. Expected: 1.3.5.6, Got=%s\n", versionString); } log_verbose("Testing the API u_versionFromString() where versionArray=NULL....\n"); u_versionFromString(NULL, "1.3.5.6"); u_versionToString(versionArray, versionString); if(strcmp(versionString, "1.3.5.6") != 0){ log_err("ERROR: u_getVersion() failed. Expected: 1.3.5.6, Got=%s\n", versionString); } log_verbose("Testing the API u_getVersion().....\n"); u_getVersion(versionArray); u_versionToString(versionArray, versionString); if(strcmp(versionString, U_ICU_VERSION) != 0){ log_err("ERROR: u_getVersion() failed. Got=%s, expected %s\n", versionString, U_ICU_VERSION); } log_verbose("Testing the API u_errorName()...\n"); str=(char*)u_errorName((UErrorCode)0); if(strcmp(str, "U_ZERO_ERROR") != 0){ log_err("ERROR: u_getVersion() failed. Expected: U_ZERO_ERROR Got=%s\n", str); } log_verbose("Testing the API u_errorName()...\n"); str=(char*)u_errorName((UErrorCode)-127); if(strcmp(str, "U_USING_DEFAULT_WARNING") != 0){ log_err("ERROR: u_getVersion() failed. Expected: U_USING_DEFAULT_WARNING Got=%s\n", str); } log_verbose("Testing the API u_errorName().. with BOGUS ERRORCODE...\n"); str=(char*)u_errorName((UErrorCode)200); if(strcmp(str, "[BOGUS UErrorCode]") != 0){ log_err("ERROR: u_getVersion() failed. Expected: [BOGUS UErrorCode] Got=%s\n", str); } { const char* dataDirectory; UChar *udataDir=0; UChar temp[100]; char *charvalue=0; log_verbose("Testing chars to UChars\n"); /* This cannot really work on a japanese system. u_uastrcpy will have different results than */ /* u_charsToUChars when there is a backslash in the string! */ /*dataDirectory=u_getDataDirectory();*/ dataDirectory="directory1"; /*no backslashes*/ udataDir=(UChar*)malloc(sizeof(UChar) * (strlen(dataDirectory) + 1)); u_charsToUChars(dataDirectory, udataDir, (strlen(dataDirectory)+1)); u_uastrcpy(temp, dataDirectory); if(u_strcmp(temp, udataDir) != 0){ log_err("ERROR: u_charsToUChars failed. Expected %s, Got %s\n", austrdup(temp), austrdup(udataDir)); } log_verbose("Testing UChars to chars\n"); charvalue=(char*)malloc(sizeof(char) * (u_strlen(udataDir) + 1)); u_UCharsToChars(udataDir, charvalue, (u_strlen(udataDir)+1)); if(strcmp(charvalue, dataDirectory) != 0){ log_err("ERROR: u_UCharsToChars failed. Expected %s, Got %s\n", charvalue, dataDirectory); } free(charvalue); free(udataDir); } log_verbose("Testing uprv_timezone()....\n"); { int32_t tzoffset = uprv_timezone(); log_verbose("Value returned from uprv_timezone = %d\n", tzoffset); if (tzoffset != 28800) { log_verbose("***** WARNING: If testing in the PST timezone, t_timezone should return 28800! *****"); } if ((tzoffset % 1800 != 0)) { log_err("FAIL: t_timezone may be incorrect. It is not a multiple of 30min."); } tzoffset=uprv_getUTCtime(); } }