ICU-9919 Add test to ensure that DateIntervalInfo.setIntervalPattern has no unwanted side effects.

X-SVN-Rev: 33194
This commit is contained in:
Travis Keep 2013-02-12 19:47:49 +00:00
parent e33bccf0e8
commit b9243a0522
2 changed files with 26 additions and 2 deletions

View 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;

View 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
*/