Skip to content

Commit

Permalink
Added additional test cases for different units and scenarios, includ…
Browse files Browse the repository at this point in the history
…ing edge cases and notes regarding CLDR handling.
  • Loading branch information
younies committed Jan 20, 2025
1 parent 7fcd356 commit 3fdec81
Showing 1 changed file with 41 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,7 @@ class TestCase {
}

@Test
public void TestConstantDenominator() {
public void TestAcceptableConstantDenominator() {
class ConstantDenominatorTestCase {
String identifier;
long expectedConstantDenominator;
Expand All @@ -1334,25 +1334,46 @@ class ConstantDenominatorTestCase {
new ConstantDenominatorTestCase("second-per-1000-minute", 1000),
new ConstantDenominatorTestCase("gram-per-1000-kilogram", 1000),
new ConstantDenominatorTestCase("meter-per-100", 100),
new ConstantDenominatorTestCase("meter-per-1", 1),
new ConstantDenominatorTestCase("meter-per-10", 10),
new ConstantDenominatorTestCase("meter-per-100", 100),
new ConstantDenominatorTestCase("meter-per-1000", 1000),
new ConstantDenominatorTestCase("meter-per-10000", 10000),
new ConstantDenominatorTestCase("meter-per-100000", 100000),
new ConstantDenominatorTestCase("meter-per-1000000", 1000000),
new ConstantDenominatorTestCase("meter-per-10000000", 10000000),
new ConstantDenominatorTestCase("meter-per-100000000", 100000000),
new ConstantDenominatorTestCase("meter-per-1000000000", 1000000000),
new ConstantDenominatorTestCase("meter-per-10000000000", 10000000000L),
new ConstantDenominatorTestCase("meter-per-100000000000", 100000000000L),
new ConstantDenominatorTestCase("meter-per-1000000000000", 1000000000000L),
new ConstantDenominatorTestCase("meter-per-10000000000000", 10000000000000L),
new ConstantDenominatorTestCase("meter-per-100000000000000", 100000000000000L),
new ConstantDenominatorTestCase("meter-per-1000000000000000", 1000000000000000L),
new ConstantDenominatorTestCase("meter-per-10000000000000000", 10000000000000000L),
new ConstantDenominatorTestCase("meter-per-100000000000000000", 100000000000000000L),
new ConstantDenominatorTestCase("meter-per-1000000000000000000", 1000000000000000000L));
new ConstantDenominatorTestCase("portion-per-1", 1),
new ConstantDenominatorTestCase("portion-per-10", 10),
new ConstantDenominatorTestCase("portion-per-100", 100),
new ConstantDenominatorTestCase("portion-per-1000", 1000),
new ConstantDenominatorTestCase("portion-per-10000", 10000),
new ConstantDenominatorTestCase("portion-per-100000", 100000),
new ConstantDenominatorTestCase("portion-per-1000000", 1000000),
new ConstantDenominatorTestCase("portion-per-10000000", 10000000),
new ConstantDenominatorTestCase("portion-per-100000000", 100000000),
new ConstantDenominatorTestCase("portion-per-1000000000", 1000000000),
new ConstantDenominatorTestCase("portion-per-10000000000", 10000000000L),
new ConstantDenominatorTestCase("portion-per-100000000000", 100000000000L),
new ConstantDenominatorTestCase("portion-per-1000000000000", 1000000000000L),
new ConstantDenominatorTestCase("portion-per-10000000000000", 10000000000000L),
new ConstantDenominatorTestCase("portion-per-100000000000000", 100000000000000L),
new ConstantDenominatorTestCase("portion-per-1000000000000000", 1000000000000000L),
new ConstantDenominatorTestCase("portion-per-10000000000000000", 10000000000000000L),
new ConstantDenominatorTestCase("portion-per-100000000000000000", 100000000000000000L),
new ConstantDenominatorTestCase("portion-per-1000000000000000000", 1000000000000000000L),
new ConstantDenominatorTestCase("portion-per-1e9", 1000000000L),
new ConstantDenominatorTestCase("portion-per-1E9", 1000000000L),
new ConstantDenominatorTestCase("portion-per-10e9", 10000000000L),
new ConstantDenominatorTestCase("portion-per-10E9", 10000000000L),
new ConstantDenominatorTestCase("portion-per-1e10", 10000000000L),
new ConstantDenominatorTestCase("portion-per-1E10", 10000000000L),
new ConstantDenominatorTestCase("portion-per-1e3-kilometer", 1000),
new ConstantDenominatorTestCase("liter-per-12345-kilometer", 12345),
new ConstantDenominatorTestCase("per-1000-kilometer", 1000),
new ConstantDenominatorTestCase("liter-per-1000-kiloliter", 1000),
// NOTE: The following constant denominator should be 0. However, since
// `100-kilometer` is treated as a unit in CLDR,
// the unit does not have a constant denominator.
// This issue should be addressed in CLDR.
new ConstantDenominatorTestCase("meter-per-100-kilometer", 0),
// NOTE: the following CLDR identifier should be invalid, but because
// `100-kilometer` is considered a unit in CLDR,
// one `100` will be considered as a unit constant denominator and the other
// `100` will be considered part of the unit.
// This issue should be addressed in CLDR.
new ConstantDenominatorTestCase("meter-per-100-100-kilometer", 100));

for (ConstantDenominatorTestCase testCase : testCases) {
MeasureUnit unit = MeasureUnit.forIdentifier(testCase.identifier);
Expand Down

0 comments on commit 3fdec81

Please sign in to comment.