Add unit rpm (#3616)

Signed-off-by: Hans Böhm <h.boehm@gmx.at>
This commit is contained in:
Hans Böhm 2023-05-17 11:47:53 +02:00 committed by GitHub
parent 6eb49577fe
commit f92424c0b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -139,6 +139,8 @@ public final class Units extends CustomUnits {
new ProductUnit<>(VOLT_AMPERE.multiply(tech.units.indriya.unit.Units.HOUR)), Energy.class);
public static final Unit<Force> NEWTON = addUnit(tech.units.indriya.unit.Units.NEWTON);
public static final Unit<Frequency> HERTZ = addUnit(tech.units.indriya.unit.Units.HERTZ);
public static final Unit<Frequency> RPM = addUnit(
new ProductUnit<>(AbstractUnit.ONE.divide(tech.units.indriya.unit.Units.MINUTE)));
public static final Unit<Intensity> IRRADIANCE = addUnit(
new ProductUnit<>(tech.units.indriya.unit.Units.WATT.divide(tech.units.indriya.unit.Units.SQUARE_METRE)));
public static final Unit<Intensity> MICROWATT_PER_SQUARE_CENTIMETRE = addUnit(
@ -276,6 +278,7 @@ public final class Units extends CustomUnits {
SimpleUnitFormat.getInstance().label(PEBIBYTE, "PiB");
SimpleUnitFormat.getInstance().alias(PEBIBYTE, "Pio");
SimpleUnitFormat.getInstance().label(PETABIT, "Pbit");
SimpleUnitFormat.getInstance().label(RPM, "rpm");
SimpleUnitFormat.getInstance().label(STANDARD_GRAVITY, "gₙ");
SimpleUnitFormat.getInstance().label(SIEMENS_PER_METRE, "S/m");
SimpleUnitFormat.getInstance().label(TERABYTE, "TB");

View File

@ -387,6 +387,13 @@ public class UnitsTest {
assertThat(converted.toString(), anyOf(is("10000 \u00B5S/cm"), is("10000 \u03BCS/cm")));
}
@Test
public void testRpm() {
QuantityType<?> oneHertz = QuantityType.valueOf("60 rpm");
QuantityType<?> converted = oneHertz.toUnit("Hz");
assertThat(converted.doubleValue(), is(closeTo(1.00, DEFAULT_ERROR)));
}
private static class QuantityEquals extends IsEqual<Quantity<?>> {
private Quantity<?> quantity;