ICU-11276 Fixing ICU4J number range test failures.

This commit is contained in:
Shane Carr 2018-09-07 12:24:47 -07:00
parent af091cc15a
commit ec40c16957
No known key found for this signature in database
GPG Key ID: FCED3B24AAB18B5C
2 changed files with 7 additions and 5 deletions

View File

@ -239,7 +239,7 @@ class NumberRangeFormatterImpl {
// Only collapse if the modifier is a unit.
// TODO: Make a better way to check for a unit?
// TODO: Handle case where the modifier has both notation and unit (compact currency)?
if (mm.containsField(NumberFormat.Field.CURRENCY) && mm.containsField(NumberFormat.Field.PERCENT)) {
if (!mm.containsField(NumberFormat.Field.CURRENCY) && !mm.containsField(NumberFormat.Field.PERCENT)) {
collapseMiddle = false;
}
} else if (fCollapse == RangeCollapse.AUTO) {

View File

@ -296,8 +296,10 @@ public class ScientificNotation extends Notation implements Cloneable {
@Override
public int getCodePointCount() {
// This method is not used for strong modifiers.
throw new AssertionError();
// NOTE: This method is only called one place, NumberRangeFormatterImpl.
// The call site only cares about != 0 and != 1.
// Return a very large value so that if this method is used elsewhere, we should notice.
return 999;
}
@Override
@ -315,10 +317,10 @@ public class ScientificNotation extends Notation implements Cloneable {
@Override
public boolean equalsModifier(Modifier other) {
if (!(other instanceof ScientificHandler)) {
if (!(other instanceof ScientificModifier)) {
return false;
}
ScientificHandler _other = (ScientificHandler) other;
ScientificModifier _other = (ScientificModifier) other;
// TODO: Check for locale symbols and settings as well? Could be less efficient.
return exponent == _other.exponent;
}