ValuesInSIUnits { public static double convertAcceleration(double acceleration, LengthUnit sourceLengthUnit, TimeUnit sourceTimeUnit) { return acceleration * LengthUnit.METERS.getUnitsIn(sourceLengthUnit) / Math.pow(getTimeUnitAsSeconds(sourceTimeUnit), 2); } private  ValuesInSIUnits(); static double convertDuration(double duration, TimeUnit sourceUnit); static double convertSpeed(double speed, LengthUnit sourceLengthUnit, TimeUnit sourceTimeUnit); static double convertAcceleration(double acceleration, LengthUnit sourceLengthUnit, TimeUnit sourceTimeUnit); static double convertJerk(double jerk, LengthUnit sourceLengthUnit, TimeUnit sourceTimeUnit);  }
@Test void convertAcceleration_whenValueGetsLarger_thenPrecisionIsMaintained() { double mmPerMsAcceleration = 1.31211; double siSpeed = mmPerMsAcceleration * 1000 * 1000 / 1000; assertThat(ValuesInSIUnits.convertAcceleration(mmPerMsAcceleration, LengthUnit.MILLIMETERS, TimeUnit.MILLISECONDS)).isCloseTo(siSpeed, withinPercentage(TOLERANCE)); }
@Test void convertAcceleration_whenValueGetsSmaller_thenPrecisionIsMaintained() { double kmPerHourAcceleration = 1.31211; double siSpeed = kmPerHourAcceleration * 1000 / (3600 * 3600); assertThat(ValuesInSIUnits.convertAcceleration(kmPerHourAcceleration, LengthUnit.KILOMETERS, TimeUnit.HOURS)).isCloseTo(siSpeed, withinPercentage(TOLERANCE)); }