unitsofmeasurement / indriya

JSR 385 - Reference Implementation
Other
122 stars 42 forks source link

fixes bug of MultiplyConverter.of(0.d) returning the identity converter #255

Closed andi-huber closed 5 years ago

andi-huber commented 5 years ago

This change is Reviewable

andi-huber commented 5 years ago

I've removed the powerLookupMap introduced with the previous merge, because it (granted) solves a particular test-case [1], but will fail once we slightly change this testcase [2]:

assertEquals(MICRO(GRAM), GRAM.divide(1_000_000)); // [1]
assertEquals(MICRO(GRAM).multiply(2), GRAM.divide(500_000)); // [2]

Converter Equality must instead be checked via ...

ComparableUnit a = (ComparableUnit) MICRO(GRAM);
ComparableUnit b = (ComparableUnit) GRAM.divide(1_000_000);
assertEquals(true, a.isEquivalentTo(b));
assertEquals(true, b.isEquivalentTo(a));