ICU-11295 Fix getNumberFormatForField so that it returns either a valid pointer or NULL.
X-SVN-Rev: 36822
This commit is contained in:
parent
ba2a065004
commit
00c6bb79bf
@ -1807,6 +1807,9 @@ void SimpleDateFormat::adoptNumberFormat(const UnicodeString& fields, NumberForm
|
||||
const NumberFormat *
|
||||
SimpleDateFormat::getNumberFormatForField(UChar field) const {
|
||||
UDateFormatField index = DateFormatSymbols::getPatternCharIndex(field);
|
||||
if (index == UDAT_FIELD_COUNT) {
|
||||
return NULL;
|
||||
}
|
||||
return &getNumberFormatByIndex(index);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
/********************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 1997-2012, International Business Machines Corporation and
|
||||
* Copyright (c) 1997-2014, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
********************************************************************/
|
||||
|
||||
@ -269,6 +269,12 @@ void IntlTestSimpleDateFormatAPI::testAPI(/*char *par*/)
|
||||
if ((double)udDate == 0.0) {
|
||||
errln("ERROR: Parsing failed using 'Y' and 'e'");
|
||||
}
|
||||
|
||||
// ====== Test ticket 11295 getNumberFormatForField returns wild pointer
|
||||
if (object.getNumberFormatForField('B') != NULL) {
|
||||
errln("B is not a valid field, "
|
||||
"getNumberFormatForField should return NULL");
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
Loading…
Reference in New Issue
Block a user