Skip to content

Commit dcfa2a7

Browse files
committed
ICU-21284 Deal with remaining unit normalization TODOs
See #1580
1 parent 9c73e15 commit dcfa2a7

File tree

4 files changed

+8
-16
lines changed

4 files changed

+8
-16
lines changed

icu4c/source/i18n/measunit_impl.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,9 @@ struct U_I18N_API SingleUnitImpl : public UMemory {
130130
if (index > other.index) {
131131
return 1;
132132
}
133-
// TODO(icu-units#70): revisit when fixing normalization. For now we're
134-
// sorting binary prefixes before SI prefixes, as per enum values order.
133+
// TODO: revisit if the spec dictates prefix sort order - it doesn't
134+
// currently. For now we're sorting binary prefixes before SI prefixes,
135+
// as per enum values order.
135136
if (unitPrefix < other.unitPrefix) {
136137
return -1;
137138
}

icu4c/source/test/intltest/measfmttest.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4050,7 +4050,7 @@ void MeasureFormatTest::TestIdentifiers() {
40504050
{"kilogram-per-meter-per-second", "kilogram-per-meter-second"},
40514051
{"kilometer-per-second-per-megaparsec", "kilometer-per-megaparsec-second"},
40524052

4053-
// TODO(ICU-21284): Add more test cases once the proper ranking is available.
4053+
// Correct order of units, as per unitQuantities in CLDR's units.xml
40544054
{"newton-meter", "newton-meter"},
40554055
{"meter-newton", "newton-meter"},
40564056
{"pound-force-foot", "pound-force-foot"},
@@ -4237,11 +4237,6 @@ void MeasureFormatTest::TestParseBuiltIns() {
42374237
continue;
42384238
}
42394239

4240-
// TODO(ICU-21284,icu-units#70): fix normalization. Until then, ignore:
4241-
if (uprv_strcmp(unit.getIdentifier(), "pound-force-foot") == 0) continue;
4242-
if (uprv_strcmp(unit.getIdentifier(), "kilowatt-hour") == 0) continue;
4243-
if (uprv_strcmp(unit.getIdentifier(), "newton-meter") == 0) continue;
4244-
42454240
// Prove that all built-in units are parseable, except "generic" temperature:
42464241
MeasureUnit parsed = MeasureUnit::forIdentifier(unit.getIdentifier(), status);
42474242
if (unit == MeasureUnit::getGenericTemperature()) {

icu4j/main/classes/core/src/com/ibm/icu/impl/units/SingleUnitImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,9 @@ int compareTo(SingleUnitImpl other) {
122122
if (index > other.index) {
123123
return 1;
124124
}
125-
// TODO(icu-units#70): revisit when fixing normalization. For now we're
126-
// sorting binary prefixes before SI prefixes, for consistency with ICU4C.
125+
// TODO: revisit if the spec dictates prefix sort order - it doesn't
126+
// currently. For now we're sorting binary prefixes before SI prefixes,
127+
// as per ICU4C's enum values order.
127128
if (this.getPrefix().getBase() < other.getPrefix().getBase()) {
128129
return 1;
129130
}

icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/MeasureUnitTest.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3689,7 +3689,7 @@ class TestCase {
36893689
new TestCase("kilogram-per-meter-per-second", "kilogram-per-meter-second"),
36903690
new TestCase("kilometer-per-second-per-megaparsec", "kilometer-per-megaparsec-second"),
36913691

3692-
// TODO(ICU-21284): Add more test cases once the proper ranking is available.
3692+
// Correct order of units, as per unitQuantities in CLDR's units.xml
36933693
new TestCase("newton-meter", "newton-meter"),
36943694
new TestCase("meter-newton", "newton-meter"),
36953695
new TestCase("pound-force-foot", "pound-force-foot"),
@@ -3872,11 +3872,6 @@ public void TestParseBuiltIns() {
38723872
continue;
38733873
}
38743874

3875-
// TODO(ICU-21284,icu-units#70): fix normalization. Until then, ignore:
3876-
if (unit.getIdentifier() == "pound-force-foot") continue;
3877-
if (unit.getIdentifier() == "kilowatt-hour") continue;
3878-
if (unit.getIdentifier() == "newton-meter") continue;
3879-
38803875
// Prove that all built-in units are parseable, except "generic" temperature:
38813876
if (unit == MeasureUnit.GENERIC_TEMPERATURE) {
38823877
try {

0 commit comments

Comments
 (0)