ICU-22143 Increase COMPACT_MAX_DIGITS from 15 to 20, needed for new ja data

This commit is contained in:
Peter Edberg 2022-09-08 22:39:29 -07:00 committed by Peter Edberg
parent 99dee47fb7
commit cfd99f3f3f
5 changed files with 15 additions and 4 deletions

View file

@ -176,7 +176,8 @@ void CompactData::CompactDataSink::put(const char *key, ResourceValue &value, UB
// length of the key minus one. We only support magnitudes less than COMPACT_MAX_DIGITS;
// ignore entries that have greater magnitude.
auto magnitude = static_cast<int8_t> (strlen(key) - 1);
if (magnitude >= COMPACT_MAX_DIGITS) {
U_ASSERT(magnitude < COMPACT_MAX_DIGITS); // debug assert
if (magnitude >= COMPACT_MAX_DIGITS) { // skip in production
continue;
}
int8_t multiplier = data.multipliers[magnitude];

View file

@ -17,7 +17,7 @@
U_NAMESPACE_BEGIN namespace number {
namespace impl {
static const int32_t COMPACT_MAX_DIGITS = 15;
static const int32_t COMPACT_MAX_DIGITS = 20;
class CompactData : public MultiplierProducer {
public:

View file

@ -114,7 +114,12 @@ static ExpectedResult kJapaneseShort[] = {
{1.23456789E11, "1200\\u5104"},
{1.23456789E12, "1.2\\u5146"},
{1.23456789E13, "12\\u5146"},
{1.23456789E14, "120\\u5146"}};
{1.23456789E14, "120\\u5146"},
{1.23456789E15, "1200\\u5146"},
{1.23456789E16, "1.2\\u4EAC"},
{1.23456789E17, "12\\u4EAC"},
{1.23456789E18, "120\\u4EAC"},
{1.23456789E19, "1200\\u4EAC"}};
static ExpectedResult kSwahiliShort[] = {
{1234.0, "elfu\\u00a01.2"},

View file

@ -34,7 +34,7 @@ public class CompactData implements MultiplierProducer {
private byte largestMagnitude;
private boolean isEmpty;
private static final int COMPACT_MAX_DIGITS = 15;
private static final int COMPACT_MAX_DIGITS = 20;
public CompactData() {
patterns = new String[(CompactData.COMPACT_MAX_DIGITS + 1) * StandardPlural.COUNT];

View file

@ -148,6 +148,11 @@ public class CompactDecimalFormatTest extends TestFmwk {
{1234567890123f, "1.2兆"},
{12345678901234f, "12兆"},
{123456789012345f, "120兆"},
{1234567890123456f, "1200兆"},
{12345678901234567f, "1.2京"},
{123456789012345678f, "12京"},
{1234567890123456789f, "120京"},
{12345678901234567890f, "1200京"},
};
Object[][] ChineseTestData = {