From ec40c16957ffc7f11e81d5a9424efe554333628d Mon Sep 17 00:00:00 2001 From: Shane Carr Date: Fri, 7 Sep 2018 12:24:47 -0700 Subject: [PATCH] ICU-11276 Fixing ICU4J number range test failures. --- .../com/ibm/icu/number/NumberRangeFormatterImpl.java | 2 +- .../src/com/ibm/icu/number/ScientificNotation.java | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/icu4j/main/classes/core/src/com/ibm/icu/number/NumberRangeFormatterImpl.java b/icu4j/main/classes/core/src/com/ibm/icu/number/NumberRangeFormatterImpl.java index b2629903922..ca842748a10 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/number/NumberRangeFormatterImpl.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/number/NumberRangeFormatterImpl.java @@ -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) { diff --git a/icu4j/main/classes/core/src/com/ibm/icu/number/ScientificNotation.java b/icu4j/main/classes/core/src/com/ibm/icu/number/ScientificNotation.java index 7b283734813..3854ff36f1c 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/number/ScientificNotation.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/number/ScientificNotation.java @@ -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; } -- 2.50.1