]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/intltest/dtfmttst.cpp
ICU-400.38.tar.gz
[apple/icu.git] / icuSources / test / intltest / dtfmttst.cpp
index 65345fc085cffbc34a83fbf0bb6eb711bf5e0d46..78b073396804b68d557c0f52ea88897fa9e13983 100644 (file)
@@ -77,7 +77,9 @@ void DateFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &nam
         /*
         TESTCASE(37,TestRelativeError);
         TESTCASE(38,TestRelativeOther);
-        */
+        TESTCASE(39,TestNumberAsStringParsing);
+         */
+        TESTCASE(37,TestNumberAsStringParsing);
         default: name = ""; break;
     }
 }
@@ -2964,6 +2966,32 @@ void DateFormatTest::TestRelativeOther(void)
 }
 */
 
+void DateFormatTest::TestNumberAsStringParsing()
+{
+    UErrorCode status = U_ZERO_ERROR;
+    UnicodeString dateString("2009 7 2 08:14:16");
+    UnicodeString datePattern("y MMMM d HH:mm:ss");
+    SimpleDateFormat *formatter = new SimpleDateFormat(datePattern, Locale(""), status);
+    UDate date1 = 0;
+    
+    formatter->setLenient(FALSE);
+    date1 = formatter->parse(dateString, status);
+    
+    if (U_FAILURE(status)) {
+        errln("FAIL: Could not parse \"2009 7 2 08:14:16\" with pattern \"y MMMM d HH:mm:ss\"");
+    } else {
+        UnicodeString formatted;
+        
+        formatter->format(date1, formatted);
+        
+        if (formatted != dateString) {
+            errln("FAIL: parsed string did not match input.");
+        }
+    }
+    
+    delete formatter;
+}
+
 
 
 #endif /* #if !UCONFIG_NO_FORMATTING */