X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/b331163bffd790ced0e88b73f44f86d49ccc48a5..340931cb2e044a2141d11567dd0f782524e32994:/icuSources/test/intltest/dtfmtrtts.cpp diff --git a/icuSources/test/intltest/dtfmtrtts.cpp b/icuSources/test/intltest/dtfmtrtts.cpp index b23aaebd..01b7c808 100644 --- a/icuSources/test/intltest/dtfmtrtts.cpp +++ b/icuSources/test/intltest/dtfmtrtts.cpp @@ -1,6 +1,8 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /*********************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2014, International Business Machines Corporation + * Copyright (c) 1997-2015, International Business Machines Corporation * and others. All Rights Reserved. ***********************************************************************/ @@ -247,7 +249,7 @@ void DateFormatRoundTripTest::test(const Locale& loc) for(style = DateFormat::FULL; style <= DateFormat::SHORT; ++style) { if (TEST_TABLE[itable++]) { - logln("Testing style " + UnicodeString(styleName((DateFormat::EStyle)style))); + logln("Testing style " + UnicodeString(styleName((DateFormat::EStyle)style))); DateFormat *df = DateFormat::createTimeInstance((DateFormat::EStyle)style, loc); if(df == NULL) { errln(UnicodeString("Could not DF::createTimeInstance ") + UnicodeString(styleName((DateFormat::EStyle)style)) + " Locale: " + loc.getDisplayName(temp)); @@ -338,8 +340,13 @@ void DateFormatRoundTripTest::test(DateFormat *fmt, const Locale &origLocale, UB for(loop = 0; loop < DEPTH; ++loop) { if (loop > 0) { d[loop] = fmt->parse(s[loop-1], status); - failure(status, "fmt->parse", s[loop-1]+" in locale: " + origLocale.getName() + " with pattern: " + pat); - status = U_ZERO_ERROR; /* any error would have been reported */ + if(U_FAILURE(status)) { + ParsePosition ppos; + (void)fmt->parse(s[loop-1], ppos); + failure(status, "fmt->parse", s[loop-1]+" in locale: " + origLocale.getName() + + " with pattern: " + pat + " has errIndex: " + ppos.getErrorIndex()); + status = U_ZERO_ERROR; /* any error would have been reported */ + } } s[loop] = fmt->format(d[loop], s[loop]); @@ -436,6 +443,19 @@ void DateFormatRoundTripTest::test(DateFormat *fmt, const Locale &origLocale, UB else if (hasZoneDisplayName && d[0] < 0) { maxSmatch = 2; } + else if (timeOnly && !isGregorian && hasZoneDisplayName && maxSmatch == 1) { + int32_t startRaw, startDst; + fmt->getTimeZone().getOffset(d[1], FALSE, startRaw, startDst, status); + failure(status, "TimeZone::getOffset"); + // If the calendar type is not Gregorian and the pattern is time only, + // the calendar implementation may use a date before 1970 as day 0. + // In this case, time zone offset of the default year might be + // different from the one at 1970-01-01 in PST and string match requires + // one more iteration. + if (startRaw + startDst != -28800000) { + maxSmatch = 2; + } + } } /* @@ -519,13 +539,16 @@ UnicodeString& DateFormatRoundTripTest::escape(const UnicodeString& src, Unicode { dst.remove(); for (int32_t i = 0; i < src.length(); ++i) { - UChar c = src[i]; - if(c < 0x0080) + UChar32 c = src.char32At(i); + if (c >= 0x10000) { + ++i; + } + if (c < 0x0080) { dst += c; - else { + } else { dst += UnicodeString("["); - char buf [8]; - sprintf(buf, "%#x", c); + char buf [12]; + sprintf(buf, "%#04x", c); dst += UnicodeString(buf); dst += UnicodeString("]"); }