You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 7, 2020. It is now read-only.
@Test
public void UnithPaTest() {
QuantityType<Pressure> hPa = new QuantityType<>(20, MetricPrefix.HECTO(SIUnits.PASCAL));
assertEquals("20 hPa", hPa.toString());
QuantityType<Pressure> hPa2 = new QuantityType<>(hPa.toString());
assertEquals(hPa, hPa2);
}
This works as expected.
@Test
public void UnitmbarTest() {
QuantityType<Pressure> mbar = new QuantityType<>(20, MetricPrefix.MILLI(SmartHomeUnits.BAR));
assertEquals("20 mbar", mbar.toString());
QuantityType<Pressure> mbar2 = new QuantityType<>(mbar.toString());
assertEquals(mbar, mbar2);
}
This fails with
java.lang.IllegalArgumentException: mbar not recognized (in 20 mbar at index 3)
at org.eclipse.smarthome.binding.onewire.internal.UtilTest.UnitmbarTest(UtilTest.java:73)
The text was updated successfully, but these errors were encountered:
@htreu, do we have to add mbar in a similar way as kWh? If so, I can provide a PR for that. However, it seems a bit strange that prefixes work for Pascal and bar when the string is constructed but only work for Pascal when it comes to parsing exactly that string.
We use the SimpleUnitFormat to parse units and it only knows a fixed set of unit symbols. Every combination has to be registered upfront.
I would happily accept a PR for adding mbar as a separate unit but in the long run we should see what other parsers exists or if we should write one ourselves to handle this in a more generic way.
This works as expected.
This fails with
The text was updated successfully, but these errors were encountered: