DecimalFormat should fail gracefully with empty string currency

Description

The ICU DecimalFormat setCurrency docs says:

However, my code in ICU 62 was written erroneously assuming that the string is always either nullptr or a valid 3-character code. A test case came up in which a user was calling the API with the empty string, causing a hard-to-debug test failure that didn't always reproduce.

The fix is simple, and I will commit it to this ticket in a few minutes.

Activity

Show:
TracBot
July 1, 2018, 12:14 AM
Trac Comment 1 by —2018-06-23T02:10:56.744Z

Commit attached to ticket.

This was a failure in the test suite; the APIdocs of setCurrency in decimfmt.h was not fully tested. I have now added a test for the behavior documented on that method.

Markus Scherer
July 25, 2018, 9:01 PM
Edited

The change looks good, but –

AFAICT the NUL character is "invariant", which means that we accept strings like "X" and "XY".
I think we should add a check like this after the "" check and before the invariant-chars check:

This could be in a separate ticket.

Fixed

Assignee

Shane Carr

Reporter

Shane Carr

Components

Labels

Reviewer

Markus Scherer

Priority

major

Time Needed

None

Fix versions

Configure