X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/b75a7d8f3b4adbae880cab104ce2c6a50eee4db2..151279e3792e85d0417b499c229886b3af724f55:/icuSources/test/intltest/caltztst.cpp diff --git a/icuSources/test/intltest/caltztst.cpp b/icuSources/test/intltest/caltztst.cpp index b9c43867..9b5b4a0d 100644 --- a/icuSources/test/intltest/caltztst.cpp +++ b/icuSources/test/intltest/caltztst.cpp @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2003, International Business Machines Corporation and + * Copyright (c) 1997-2010, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ /* @@ -24,11 +24,15 @@ DateFormat* CalendarTimeZoneTest::fgDateFormat = 0; Calendar* CalendarTimeZoneTest::fgCalendar = 0; -UBool CalendarTimeZoneTest::failure(UErrorCode status, const char* msg) +UBool CalendarTimeZoneTest::failure(UErrorCode status, const char* msg, UBool possibleDataError) { if (U_FAILURE(status)) { - errln(UnicodeString("FAIL: ") + msg + " failed, error " + u_errorName(status)); + if (possibleDataError) { + dataerrln(UnicodeString("FAIL: ") + msg + " failed, error " + u_errorName(status)); + } else { + errcheckln(status, UnicodeString("FAIL: ") + msg + " failed, error " + u_errorName(status)); + } return TRUE; } return FALSE; @@ -57,7 +61,7 @@ DateFormat* CalendarTimeZoneTest::getDateFormat() { delete theFormat; theFormat = 0; - errln("FAIL: Could not create SimpleDateFormat"); + dataerrln("FAIL: Could not create SimpleDateFormat - %s", u_errorName(status)); } } @@ -104,7 +108,7 @@ Calendar* CalendarTimeZoneTest::getCalendar() { delete theCalendar; theCalendar = 0; - errln("FAIL: Calendar::createInstance failed"); + dataerrln("FAIL: Calendar::createInstance failed: %s", u_errorName(status)); } } return theCalendar; @@ -152,6 +156,25 @@ CalendarTimeZoneTest::dateToString(UDate d, UnicodeString& str) return str; } +UnicodeString& +CalendarTimeZoneTest::dateToString(UDate d, UnicodeString& str, + const TimeZone& tz) +{ + str.remove(); + DateFormat* format = getDateFormat(); + if (format == 0) + { + str += "DATE_FORMAT_FAILURE"; + return str; + } + TimeZone* save = format->getTimeZone().clone(); + format->setTimeZone(tz); + format->format(d, str); + format->adoptTimeZone(save); + releaseDateFormat(format); + return str; +} + // Utility methods to create a date. This is useful for converting Java constructs // which create a Date object. UDate @@ -166,7 +189,7 @@ CalendarTimeZoneTest::date(int32_t y, int32_t m, int32_t d, int32_t hr, int32_t releaseCalendar(cal); if (U_FAILURE(status)) { - errln("FAIL: Calendar::getTime failed"); + errln("FAIL: Calendar::getTime failed: %s", u_errorName(status)); return 0.0; } return dt;