ICU-12054 If format has no fields, first FieldPositionIterator::next should return FALSE; fix ufieldpositer_next description
X-SVN-Rev: 39241
This commit is contained in:
parent
bdde6c0c3b
commit
67b23a4aa6
@ -62,7 +62,10 @@ void FieldPositionIterator::setData(UVector32 *adopt, UErrorCode& status) {
|
||||
// Verify that adopt has valid data, and update status if it doesn't.
|
||||
if (U_SUCCESS(status)) {
|
||||
if (adopt) {
|
||||
if ((adopt->size() % 3) != 0) {
|
||||
if (adopt->size() == 0) {
|
||||
delete adopt;
|
||||
adopt = NULL;
|
||||
} else if ((adopt->size() % 3) != 0) {
|
||||
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
} else {
|
||||
for (int i = 1; i < adopt->size(); i += 3) {
|
||||
|
@ -86,8 +86,8 @@ U_NAMESPACE_END
|
||||
|
||||
/**
|
||||
* Get information for the next field in the formatted string to which this
|
||||
* UFieldPositionIterator currently applies, or return FALSE if there are
|
||||
* no more fields.
|
||||
* UFieldPositionIterator currently applies, or return a negative value if there
|
||||
* are no more fields.
|
||||
* @param fpositer
|
||||
* A pointer to the UFieldPositionIterator object containing iteration
|
||||
* state for the format fields.
|
||||
|
@ -1748,6 +1748,7 @@ static void TestParseErrorReturnValue(void) {
|
||||
static const char localeForFields[] = "en_US";
|
||||
/* zoneGMT[]defined above */
|
||||
static const UDate date2015Feb25 = 1424841000000.0; /* Wednesday, February 25, 2015 at 5:10:00 AM GMT */
|
||||
static const UChar patNoFields[] = { 0x0027, 0x0078, 0x0078, 0x0078, 0x0027, 0 }; /* "'xxx'" */
|
||||
|
||||
typedef struct {
|
||||
int32_t field;
|
||||
@ -1837,6 +1838,19 @@ static void TestFormatForFields(void) {
|
||||
}
|
||||
}
|
||||
|
||||
udat_applyPattern(udfmt, FALSE, patNoFields, -1);
|
||||
status = U_ZERO_ERROR;
|
||||
ulen = udat_formatForFields(udfmt, date2015Feb25, ubuf, kUBufFieldsLen, fpositer, &status);
|
||||
if ( U_FAILURE(status) ) {
|
||||
log_err("udat_formatForFields with no-field pattern fails, status %s\n", u_errorName(status));
|
||||
} else {
|
||||
field = ufieldpositer_next(fpositer, &beginPos, &endPos);
|
||||
if (field >= 0) {
|
||||
log_err("udat_formatForFields with no-field pattern as \"%s\"; expect field < 0, get field %d range %d-%d\n",
|
||||
aescstrdup(ubuf, ulen), field, beginPos, endPos);
|
||||
}
|
||||
}
|
||||
|
||||
ucal_close(ucal);
|
||||
udat_close(udfmt);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user