indriya
indriya copied to clipboard
Incorrect equality between Quantity
The following test defines two quantities that should be equals but because they are using a different Unit class they are not. I think this impacts the usability of the library. Regards.
@Test
public void shouldNotEqualizeQuantities() {
// uses TransformedUnit
Quantity<Mass> w1 = Quantities.getQuantity(12.5, MetricPrefix.KILO(GRAM));
// uses BasicUnit
Quantity<Mass> w2 = (Quantity<Mass>) Quantities.getQuantity("12.5 kg");
assertFalse(w1.equals(w2));
assertFalse(w2.equals(w1));
// workaround
assertEquals(w1.toString(), w2.toString());
}