]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/intltest/dadrfmt.cpp
ICU-511.25.tar.gz
[apple/icu.git] / icuSources / test / intltest / dadrfmt.cpp
index a3c58362f159c944c34bc8091793163a948716b6..c3a533aede8b7ee21ba6ba8c076882187e2cf27b 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1997-2010, International Business Machines Corporation and
+ * Copyright (c) 1997-2010,2012, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 
  * others. All Rights Reserved.
  ********************************************************************/
 
@@ -73,14 +73,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
             // 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 { 
                {
             // 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"
                     "DATE=SHORT,TIME=SHORT",
                     "ERA=1,YEAR=2007,MONTH=AUGUST,DATE=8,HOUR=18,MINUTE=54,SECOND=12",
                     "8/8/2007 6:54pm"
@@ -130,6 +132,11 @@ void DataDrivenFormatTest::testConvertDate(TestData *testData,
             errln("case %d: No 'locale' line.", n);
             continue;
         }
             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);
         UnicodeString spec = currentCase->getString("spec", status);
         if(U_FAILURE(status)) {
             errln("case %d: No 'spec' line.", n);
@@ -175,6 +182,13 @@ void DataDrivenFormatTest::testConvertDate(TestData *testData,
         if(U_FAILURE(status)) {
             errln("case %d: could not create calendar from %s", n, calLoc);
         }
         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)) {
 
         // parse 'date'
         if(date.startsWith(kMILLIS)) {
@@ -197,8 +211,13 @@ void DataDrivenFormatTest::testConvertDate(TestData *testData,
             for (int q=0; q<UCAL_FIELD_COUNT; q++) {
                 if (fromSet.isSet((UCalendarDateFields)q)) {
                     //int32_t oldv = cal->get((UCalendarDateFields)q, status);
             for (int q=0; q<UCAL_FIELD_COUNT; q++) {
                 if (fromSet.isSet((UCalendarDateFields)q)) {
                     //int32_t oldv = cal->get((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);
                 }
             }
                     //int32_t newv = cal->get((UCalendarDateFields)q, status);
                 }
             }