]> granicus.if.org Git - icu/commitdiff
ICU-21284 Deal with remaining unit normalization TODOs
authorHugo van der Merwe <17109322+hugovdm@users.noreply.github.com>
Tue, 16 Feb 2021 13:04:59 +0000 (13:04 +0000)
committerHugo van der Merwe <17109322+hugovdm@users.noreply.github.com>
Tue, 16 Feb 2021 19:52:12 +0000 (20:52 +0100)
See #1580

icu4c/source/i18n/measunit_impl.h
icu4c/source/test/intltest/measfmttest.cpp
icu4j/main/classes/core/src/com/ibm/icu/impl/units/SingleUnitImpl.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/MeasureUnitTest.java

index 0f5aac488d2022ad396aa217053d9bbaed78ae3f..645e8212cfcb03897b2e674e4492c5b00d5c993a 100644 (file)
@@ -130,8 +130,9 @@ struct U_I18N_API SingleUnitImpl : public UMemory {
         if (index > other.index) {
             return 1;
         }
-        // TODO(icu-units#70): revisit when fixing normalization. For now we're
-        // sorting binary prefixes before SI prefixes, as per enum values order.
+        // TODO: revisit if the spec dictates prefix sort order - it doesn't
+        // currently. For now we're sorting binary prefixes before SI prefixes,
+        // as per enum values order.
         if (unitPrefix < other.unitPrefix) {
             return -1;
         }
index c9f6b4261d2d39e7d6e9fe44ffcdde6ff87e3822..e5dfcbb8d49fbb08efb4ff788a44eb7f75fb8644 100644 (file)
@@ -4050,7 +4050,7 @@ void MeasureFormatTest::TestIdentifiers() {
         {"kilogram-per-meter-per-second", "kilogram-per-meter-second"},
         {"kilometer-per-second-per-megaparsec", "kilometer-per-megaparsec-second"},
 
-        // TODO(ICU-21284): Add more test cases once the proper ranking is available.
+        // Correct order of units, as per unitQuantities in CLDR's units.xml
         {"newton-meter", "newton-meter"},
         {"meter-newton", "newton-meter"},
         {"pound-force-foot", "pound-force-foot"},
@@ -4237,11 +4237,6 @@ void MeasureFormatTest::TestParseBuiltIns() {
             continue;
         }
 
-        // TODO(ICU-21284,icu-units#70): fix normalization. Until then, ignore:
-        if (uprv_strcmp(unit.getIdentifier(), "pound-force-foot") == 0) continue;
-        if (uprv_strcmp(unit.getIdentifier(), "kilowatt-hour") == 0) continue;
-        if (uprv_strcmp(unit.getIdentifier(), "newton-meter") == 0) continue;
-
         // Prove that all built-in units are parseable, except "generic" temperature:
         MeasureUnit parsed = MeasureUnit::forIdentifier(unit.getIdentifier(), status);
         if (unit == MeasureUnit::getGenericTemperature()) {
index dd66d742a82a24d064391dadc2ba8c6591253d63..dd976cb55530fc75acef5718cfe58114bf1d7451 100644 (file)
@@ -122,8 +122,9 @@ public class SingleUnitImpl {
         if (index > other.index) {
             return 1;
         }
-        // TODO(icu-units#70): revisit when fixing normalization. For now we're
-        // sorting binary prefixes before SI prefixes, for consistency with ICU4C.
+        // TODO: revisit if the spec dictates prefix sort order - it doesn't
+        // currently. For now we're sorting binary prefixes before SI prefixes,
+        // as per ICU4C's enum values order.
         if (this.getPrefix().getBase() < other.getPrefix().getBase()) {
             return 1;
         }
index e7e28d18ee5dc4635ff17c9c834ae551b48b2ae3..eda3f75a0c5e3d096c836d9d577e28adec85328c 100644 (file)
@@ -3689,7 +3689,7 @@ public class MeasureUnitTest extends TestFmwk {
             new TestCase("kilogram-per-meter-per-second", "kilogram-per-meter-second"),
             new TestCase("kilometer-per-second-per-megaparsec", "kilometer-per-megaparsec-second"),
 
-            // TODO(ICU-21284): Add more test cases once the proper ranking is available.
+            // Correct order of units, as per unitQuantities in CLDR's units.xml
             new TestCase("newton-meter", "newton-meter"),
             new TestCase("meter-newton", "newton-meter"),
             new TestCase("pound-force-foot", "pound-force-foot"),
@@ -3872,11 +3872,6 @@ public class MeasureUnitTest extends TestFmwk {
                 continue;
             }
 
-            // TODO(ICU-21284,icu-units#70): fix normalization. Until then, ignore:
-            if (unit.getIdentifier() == "pound-force-foot") continue;
-            if (unit.getIdentifier() == "kilowatt-hour") continue;
-            if (unit.getIdentifier() == "newton-meter") continue;
-
             // Prove that all built-in units are parseable, except "generic" temperature:
             if (unit == MeasureUnit.GENERIC_TEMPERATURE) {
                 try {