1 package org.djunits.unit;
2
3 import static org.junit.jupiter.api.Assertions.assertEquals;
4 import static org.junit.jupiter.api.Assertions.assertTrue;
5
6 import java.util.Locale;
7
8 import org.djunits.unit.unitsystem.UnitSystem;
9 import org.junit.jupiter.api.BeforeEach;
10 import org.junit.jupiter.api.Test;
11
12
13
14
15
16
17
18
19 public class PowerUnitTest extends AbstractLinearUnitTest<PowerUnit>
20 {
21
22
23
24 @BeforeEach
25 public final void setup()
26 {
27 Locale.setDefault(new Locale("en"));
28 }
29
30
31
32
33 @Test
34 public final void conversions()
35 {
36 assertEquals("kgm2/s3", PowerUnit.SI.getQuantity().getSiDimensions().toString(true, false));
37 checkUnitRatioNameAndAbbreviation(PowerUnit.WATT, 1, 0.00000001, "watt", "W");
38 checkUnitRatioNameAndAbbreviation(PowerUnit.FOOT_POUND_FORCE_PER_HOUR, 0.00037661608333, 0.0000000001,
39 "foot pound-force per hour", "ft.lbf/h");
40 checkUnitRatioNameAndAbbreviation(PowerUnit.FOOT_POUND_FORCE_PER_MINUTE, 0.022596965, 0.000001,
41 "foot pound-force per minute", "ft.lbf/min");
42
43 assertEquals(0.01666667,
44 getMultiplicationFactorTo(PowerUnit.FOOT_POUND_FORCE_PER_HOUR, PowerUnit.FOOT_POUND_FORCE_PER_MINUTE),
45 0.0000001, "one FOOT POUND FORCE PER HOUR is about 0.0166667 FOOT POUND FORCE PER MINUTE");
46 assertEquals(60, getMultiplicationFactorTo(PowerUnit.FOOT_POUND_FORCE_PER_MINUTE, PowerUnit.FOOT_POUND_FORCE_PER_HOUR),
47 0.000001, "one FOOT POUND FORCE PER MINUTE is 60 FOOT POUND FORCE PER HOUR");
48
49 checkUnitRatioNameAndAbbreviation(PowerUnit.KILOWATT, 1000, 0.001, "kilowatt", "kW");
50 checkUnitRatioNameAndAbbreviation(PowerUnit.MEGAWATT, 1000000, 1, "megawatt", "MW");
51 checkUnitRatioNameAndAbbreviation(PowerUnit.GIGAWATT, 1e9, 1e3, "gigawatt", "GW");
52 checkUnitRatioNameAndAbbreviation(PowerUnit.FOOT_POUND_FORCE_PER_SECOND, 1.3558179, 0.000001,
53 "foot pound-force per second", "ft.lbf/s");
54 checkUnitRatioNameAndAbbreviation(PowerUnit.HORSEPOWER_METRIC, 735.49875, 0.00001, "horsepower (metric)", "hp(M)");
55 }
56
57
58
59
60 @Test
61 public final void createPowerUnitUnit()
62 {
63 PowerUnit myMU = PowerUnit.WATT.deriveLinear(250, "pnp", "Person", UnitSystem.OTHER);
64 assertTrue(null != myMU, "Can create a new PowerUnit");
65 checkUnitRatioNameAndAbbreviation(myMU, 250, 1, "Person", "pnp");
66 PowerUnit.BASE.unregister(myMU);
67 }
68
69 }