]> granicus.if.org Git - icu/commitdiff
ICU-8675 Simple test case for checking stand alone GMT parsing multiple times.
authorYoshito Umaoka <y.umaoka@gmail.com>
Wed, 6 Jul 2011 16:42:25 +0000 (16:42 +0000)
committerYoshito Umaoka <y.umaoka@gmail.com>
Wed, 6 Jul 2011 16:42:25 +0000 (16:42 +0000)
X-SVN-Rev: 30282

icu4c/source/test/intltest/dtfmttst.cpp
icu4c/source/test/intltest/dtfmttst.h

index 7f6078874aa1fc089614859920c06274dd5fa954..07c782e404b3df3d567aeb3ce8d657096d5f3aac 100644 (file)
@@ -82,9 +82,10 @@ void DateFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &nam
         TESTCASE(42,TestISOEra);
         TESTCASE(43,TestFormalChineseDate);
         TESTCASE(44,TestNumberAsStringParsing);
+        TESTCASE(45,TestStandAloneGMTParse);
         /*
-        TESTCASE(45,TestRelativeError);
-        TESTCASE(46,TestRelativeOther);
+        TESTCASE(46,TestRelativeError);
+        TESTCASE(47,TestRelativeOther);
         */
         default: name = ""; break;
     }
@@ -3577,8 +3578,27 @@ void DateFormatTest::TestFormalChineseDate() {
         dataerrln((UnicodeString)"FAIL: parsed -> " + parsedres + " expected -> " + expres); 
         delete usf;
     }
-    delete sdf;         
-} 
+    delete sdf;
+}
+
+// Test case for #8675
+// Incorrect parse offset with stand alone GMT string on 2nd or later iteration.
+void DateFormatTest::TestStandAloneGMTParse() {
+    UErrorCode status = U_ZERO_ERROR;
+    SimpleDateFormat *sdf = new SimpleDateFormat("ZZZZ", Locale(""), status);
+    failure(status, "new SimpleDateFormat");
+
+    UnicodeString inText("GMT$$$");
+    for (int32_t i = 0; i < 10; i++) {
+        ParsePosition pos(0);
+        sdf->parse(inText, pos);
+        if (pos.getIndex() != 3) {
+            errln((UnicodeString)"FAIL: Incorrect output parse position: actual=" + pos.getIndex() + " expected=3");
+        }
+    }
+
+    delete sdf;
+}
 
 #endif /* #if !UCONFIG_NO_FORMATTING */
 
index 58bb0a820cde262d9e285eb368d5d7290d1cdc53..ccf46c7ebfd292b48b428a7ed954924bfbc1d924 100644 (file)
@@ -171,6 +171,8 @@ public: // package
 
     void TestFormalChineseDate(void);
 
+    void TestStandAloneGMTParse(void);
+
 public:
     /**
      * Test host-specific formatting.