[Units] Add MK⁻¹ unit alias (#4433)

* Add unit alias for Micro Reciprocal Kelvin

Signed-off-by: AndrewFG <software@whitebear.ch>
This commit is contained in:
Andrew Fiddian-Green 2024-11-04 10:01:20 +00:00 committed by GitHub
parent bc6731157c
commit 591d8d956a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View File

@ -293,7 +293,9 @@ public final class Units extends CustomUnits {
SimpleUnitFormat.getInstance().label(MILLIAMPERE_HOUR, "mAh");
SimpleUnitFormat.getInstance().label(MILLIBAR, "mbar");
SimpleUnitFormat.getInstance().label(MILLIMETRE_OF_MERCURY, MILLIMETRE_OF_MERCURY.getSymbol());
SimpleUnitFormat.getInstance().label(MIRED, "mired");
SimpleUnitFormat.getInstance().label(MIRED, "MK⁻¹");
SimpleUnitFormat.getInstance().alias(MIRED, "mired");
SimpleUnitFormat.getInstance().alias(MIRED, "mirek");
SimpleUnitFormat.getInstance().label(PARTS_PER_BILLION, "ppb");
SimpleUnitFormat.getInstance().label(PARTS_PER_MILLION, "ppm");
SimpleUnitFormat.getInstance().label(PETABYTE, "PB");

View File

@ -431,6 +431,17 @@ public class UnitsTest {
assertThat(converted2.doubleValue(), is(closeTo(12.0, DEFAULT_ERROR)));
}
@Test
public void testColorTemperatureAliases() {
QuantityType<?> value;
value = QuantityType.valueOf("20 mired");
assertEquals(Units.MIRED, value.getUnit());
value = QuantityType.valueOf("20 mirek");
assertEquals(Units.MIRED, value.getUnit());
value = QuantityType.valueOf("20 MK⁻¹");
assertEquals(Units.MIRED, value.getUnit());
}
private static class QuantityEquals extends IsEqual<Quantity<?>> {
private Quantity<?> quantity;