ICU-9230 Merge r31664 into maint-49

X-SVN-Rev: 31670
This commit is contained in:
Michael Ow 2012-04-02 16:15:41 +00:00
parent 73be39e37e
commit 2b1a711396
3 changed files with 41 additions and 2 deletions

View file

@ -438,6 +438,7 @@ SimpleDateFormat::SimpleDateFormat(const Locale& locale,
SimpleDateFormat::SimpleDateFormat(const SimpleDateFormat& other)
: DateFormat(other),
fLocale(other.fLocale),
fSymbols(NULL),
fTimeZoneFormat(NULL),
fNumberFormatters(NULL),
@ -471,6 +472,8 @@ SimpleDateFormat& SimpleDateFormat::operator=(const SimpleDateFormat& other)
// TimeZoneFormat in ICU4C only depends on a locale for now
if (fLocale != other.fLocale) {
delete fTimeZoneFormat;
fTimeZoneFormat = NULL; // forces lazy instantiation with the other locale
fLocale = other.fLocale;
}
fDefaultCapitalizationContext = other.fDefaultCapitalizationContext;

View file

@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
* Copyright (c) 1997-2011, International Business Machines Corporation and
* Copyright (c) 1997-2012, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
@ -55,6 +55,7 @@ DateFormatRegressionTest::runIndexedTest( int32_t index, UBool exec, const char*
CASE(24,Test714)
CASE(25,Test1684)
CASE(26,Test5554)
CASE(27,Test9237)
default: name = ""; break;
}
}
@ -1461,6 +1462,40 @@ void DateFormatRegressionTest::Test5554(void)
delete sdf;
}
void DateFormatRegressionTest::Test9237(void)
{
UErrorCode status = U_ZERO_ERROR;
UnicodeString pattern("VVVV");
SimpleDateFormat fmt(pattern, status); // default locale
SimpleDateFormat fmtDE(pattern, Locale("de_DE"), status);
if (U_FAILURE(status)) {
dataerrln("Error constructing SimpleDateFormat");
return;
}
// copy constructor
SimpleDateFormat fmtCopyDE(fmtDE);
UnicodeString resDE, resCopyDE;
fmtDE.format(0.0, resDE);
fmtCopyDE.format(0.0, resCopyDE);
if (resDE != resCopyDE) {
errln(UnicodeString("Error: different result by the copied instance - org:") + resDE + " copy:" + resCopyDE);
}
// test for assignment operator
fmt = fmtDE;
UnicodeString resAssigned;
fmt.format(0.0, resAssigned);
if (resDE != resAssigned) {
errln(UnicodeString("Error: different results by the assigned instance - org:") + resDE + " assigned:" + resAssigned);
}
}
#endif /* #if !UCONFIG_NO_FORMATTING */
//eof

View file

@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
* Copyright (c) 1997-2007, International Business Machines Corporation and
* Copyright (c) 1997-2012, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
@ -51,6 +51,7 @@ public:
void Test714(void);
void Test1684(void);
void Test5554(void);
void Test9237(void);
};
#endif /* #if !UCONFIG_NO_FORMATTING */