X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/729e4ab9bc6618bc3d8a898e575df7f4019e29ca..refs/heads/master:/icuSources/test/intltest/dadrfmt.cpp?ds=inline diff --git a/icuSources/test/intltest/dadrfmt.cpp b/icuSources/test/intltest/dadrfmt.cpp index a3c58362..a382bd5e 100644 --- a/icuSources/test/intltest/dadrfmt.cpp +++ b/icuSources/test/intltest/dadrfmt.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-2010, International Business Machines Corporation and + * Copyright (c) 1997-2013 International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ @@ -73,14 +75,16 @@ void DataDrivenFormatTest::runIndexedTest(int32_t index, UBool exec, /* - * Headers { "locale","spec", "date", "str"} + * Headers { "locale", "zone", "spec", "date", "str"} // locale: locale including calendar type + // zone: time zone name, or "" to not explicitly set zone // spec: either 'PATTERN=y mm h' etc, or 'DATE=SHORT,TIME=LONG' // date: either an unsigned long (millis), or a calendar spec ERA=0,YEAR=1, etc.. applied to the calendar type specified by the locale // str: the expected unicode string Cases { { - "en_US@calendar=gregorian", + "en_US@calendar=gregorian", + "", "DATE=SHORT,TIME=SHORT", "ERA=1,YEAR=2007,MONTH=AUGUST,DATE=8,HOUR=18,MINUTE=54,SECOND=12", "8/8/2007 6:54pm" @@ -112,6 +116,7 @@ void DataDrivenFormatTest::testConvertDate(TestData *testData, DateTimeStyleSet styleSet; UnicodeString pattern; UBool usePattern = FALSE; + (void)usePattern; // Suppress unused warning. CalendarFieldsSet fromSet; UDate fromDate = 0; UBool useDate = FALSE; @@ -130,6 +135,11 @@ void DataDrivenFormatTest::testConvertDate(TestData *testData, errln("case %d: No 'locale' line.", n); continue; } + UnicodeString zone = currentCase->getString("zone", status); + if (U_FAILURE(status)) { + errln("case %d: No 'zone' line.", n); + continue; + } UnicodeString spec = currentCase->getString("spec", status); if(U_FAILURE(status)) { errln("case %d: No 'spec' line.", n); @@ -175,6 +185,13 @@ void DataDrivenFormatTest::testConvertDate(TestData *testData, if(U_FAILURE(status)) { errln("case %d: could not create calendar from %s", n, calLoc); } + + if (zone.length() > 0) { + TimeZone * tz = TimeZone::createTimeZone(zone); + cal->setTimeZone(*tz); + format->setTimeZone(*tz); + delete tz; + } // parse 'date' if(date.startsWith(kMILLIS)) { @@ -197,8 +214,13 @@ void DataDrivenFormatTest::testConvertDate(TestData *testData, for (int q=0; qget((UCalendarDateFields)q, status); - cal->add((UCalendarDateFields)q, - fromSet.get((UCalendarDateFields)q), status); + if (q == UCAL_DATE) { + cal->add((UCalendarDateFields)q, + fromSet.get((UCalendarDateFields)q), status); + } else { + cal->set((UCalendarDateFields)q, + fromSet.get((UCalendarDateFields)q)); + } //int32_t newv = cal->get((UCalendarDateFields)q, status); } }