]> granicus.if.org Git - icu/commitdiff
ICU-9919 Add test to ensure that DateIntervalInfo.setIntervalPattern has no unwanted...
authorTravis Keep <keep94@gmail.com>
Tue, 12 Feb 2013 19:47:49 +0000 (19:47 +0000)
committerTravis Keep <keep94@gmail.com>
Tue, 12 Feb 2013 19:47:49 +0000 (19:47 +0000)
X-SVN-Rev: 33194

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

index 26d848470f1a979aea0bc06ca6d1671300a09b21..a1a7f4e14e03c165d1c790b33a215cf1a0f33489 100644 (file)
@@ -45,7 +45,8 @@ void DateIntervalFormatTest::runIndexedTest( int32_t index, UBool exec, const ch
         TESTCASE(0, testAPI);
         TESTCASE(1, testFormat);
         TESTCASE(2, testFormatUserDII);
-        TESTCASE(3, testStress);
+        TESTCASE(3, testSetIntervalPatternNoSideEffect);
+        TESTCASE(4, testStress);
         default: name = ""; break;
     }
 }
@@ -1102,6 +1103,23 @@ void DateIntervalFormatTest::testFormatUserDII() {
 }
 
 
+void DateIntervalFormatTest::testSetIntervalPatternNoSideEffect() {
+    UErrorCode ec = U_ZERO_ERROR;
+    DateIntervalInfo* dtitvinf = new DateIntervalInfo(ec);
+    UnicodeString expected;
+    dtitvinf->getIntervalPattern(ctou("yMd"), UCAL_DATE, expected, ec);
+    dtitvinf->setIntervalPattern(ctou("yMd"), UCAL_DATE, ctou("M/d/y \\u2013 d"), ec);
+    delete dtitvinf;
+    dtitvinf = new DateIntervalInfo(ec);
+    UnicodeString actual;
+    dtitvinf->getIntervalPattern(ctou("yMd"), UCAL_DATE, actual, ec);
+    delete dtitvinf;
+    if (expected != actual) {
+        errln("DateIntervalInfo.setIntervalPattern should have no side effects.");
+    }
+}
+
+
 void DateIntervalFormatTest::expectUserDII(const char** data, 
                                            int32_t data_length) {
     int32_t i = 0;
index 847de1c918b811cbd87905a5e7212a47636246a8..3f62b09eb1c46bb1b6553dd865517e498494aac2 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 2008, International Business Machines Corporation and
+ * Copyright (c) 2008-2013 International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 
@@ -36,6 +36,12 @@ public:
      */
     void testFormatUserDII();
 
+    /**
+     * Test for no unwanted side effects when setting
+     * interval patterns.
+     */
+    void testSetIntervalPatternNoSideEffect();
+
     /**
      * Stress test -- stress test formatting on 40 locales
      */