ICU-21730 Check unit aliases support.

See #1804
This commit is contained in:
Younies 2021-08-31 13:13:13 +00:00 committed by Younies Mahmoud
parent a300d8dd02
commit f811ae946f
4 changed files with 27 additions and 0 deletions

View 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

View 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) {

View 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.
//

View 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();