]> granicus.if.org Git - icu/commitdiff
ICU-21730 Check unit aliases support.
authorYounies <younies.mahmoud@gmail.com>
Tue, 31 Aug 2021 13:13:13 +0000 (13:13 +0000)
committerYounies Mahmoud <younies@chromium.org>
Tue, 31 Aug 2021 16:34:12 +0000 (18:34 +0200)
See #1804

icu4c/source/test/intltest/measfmttest.cpp
icu4c/source/test/intltest/units_test.cpp
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/MeasureUnitTest.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/impl/UnitsTest.java

index 94bf5e8aa103ca93446c637904fe739191204b3c..3ea8facca3ccff1a05d1e1aedabd4e05626ac0f4 100644 (file)
@@ -4473,6 +4473,12 @@ void MeasureFormatTest::TestIdentifiers() {
         {"zebibyte", "zebibyte"},
         {"yobibyte", "yobibyte"},
 
+        // Testing aliases
+        {"foodcalorie", "foodcalorie"},
+        {"dot-per-centimeter", "dot-per-centimeter"},
+        {"dot-per-inch", "dot-per-inch"},
+        {"dot", "dot"},
+
         // Testing sort order of prefixes.
         //
         // TODO(icu-units#70): revisit when fixing normalization. For now we're
index 87cd16dd60f68ccf52880f08f6dea9c74f1d23a3..5315182cc83dc47ac087992f0b64814f673f5b79 100644 (file)
@@ -325,6 +325,15 @@ void UnitsTest::testConverter() {
         // Fuel Consumption
         {"cubic-meter-per-meter", "mile-per-gallon", 2.1383143939394E-6, 1.1},
         {"cubic-meter-per-meter", "mile-per-gallon", 2.6134953703704E-6, 0.9},
+
+        // Test Aliases
+        // Alias is just another name to the same unit. Therefore, converting
+        // between them should be the same.
+        {"foodcalorie", "kilocalorie", 1.0, 1.0},
+        {"dot-per-centimeter", "pixel-per-centimeter", 1.0, 1.0},
+        {"dot-per-inch", "pixel-per-inch", 1.0, 1.0},
+        {"dot", "pixel", 1.0, 1.0},
+
     };
 
     for (const auto &testCase : testCases) {
index 019edaff505d1e8a6154bca9434b174482f73cc4..2916a955d5218cb0d5eacb43097153a60a49aa02 100644 (file)
@@ -3923,6 +3923,11 @@ public class MeasureUnitTest extends TestFmwk {
             new TestCase("exbibyte", "exbibyte"),
             new TestCase("zebibyte", "zebibyte"),
             new TestCase("yobibyte", "yobibyte"),
+            // Testing aliases
+            new TestCase("foodcalorie", "foodcalorie"),
+            new TestCase("dot-per-centimeter", "dot-per-centimeter"),
+            new TestCase("dot-per-inch", "dot-per-inch"),
+            new TestCase("dot", "dot"),
 
             // Testing sort order of prefixes.
             //
index 646856669e9f83bf12d71c7703479ded62da39ea..8c91c7aba896b8c79a5f2400c083029cd460ba77 100644 (file)
@@ -436,6 +436,13 @@ public class UnitsTest {
                 // Fuel Consumption
                 new TestData("cubic-meter-per-meter", "mile-per-gallon", 2.1383143939394E-6, 1.1),
                 new TestData("cubic-meter-per-meter", "mile-per-gallon", 2.6134953703704E-6, 0.9),
+                // Test Aliases
+                // Alias is just another name to the same unit. Therefore, converting
+                // between them should be the same.
+                new TestData("foodcalorie", "kilocalorie", 1.0, 1.0),
+                new TestData("dot-per-centimeter", "pixel-per-centimeter", 1.0, 1.0),
+                new TestData("dot-per-inch", "pixel-per-inch", 1.0, 1.0),
+                new TestData("dot", "pixel", 1.0, 1.0),
         };
 
         ConversionRates conversionRates = new ConversionRates();