Convert { @NonNull public static String speed(double mps) { final double smallMps = metric ? 10 * KPH : 10 * MPH; if (mps < smallMps) { return speed(mps, 1, true); } else { return speed(mps, 0, true); } }  static double kts2mps(double knots); @NonNull static String altitude(double m); @NonNull static String distance(double m); @NonNull static String distance(double m, int precision, boolean units); @NonNull static String distance2(double m, int precision); @NonNull static String distance3(double m); @NonNull static String speed(double mps); @NonNull static String speed(double mps, int precision, boolean units); @NonNull static String glide(double glideRatio, int precision, boolean units); @NonNull static String glide(double groundSpeed, double climb, int precision, boolean units); @NonNull static String glide2(double groundSpeed, double climb, int precision, boolean units); @NonNull static String pressure(double hPa); @NonNull static String angle(double degrees); @NonNull static String angle2(double degrees); @NonNull static String bearing2(double degrees); static boolean metric; static final double FT; static final double MPH; static final double KPH; static final float MPHf; static final float KPHf; static final String GLIDE_STATIONARY; static final String GLIDE_LEVEL; static final String GLIDE_VERTICAL; }
@Test public void convertSpeed() { Convert.metric = false; assertEquals("0.0 mph", Convert.speed(0.0)); assertEquals("9.9 mph", Convert.speed(9.9 * Convert.MPH)); assertEquals("22 mph", Convert.speed(10.0)); assertEquals("224 mph", Convert.speed(100.0)); assertEquals("224 mph", Convert.speed(100.0, 0, true)); assertEquals("224", Convert.speed(100.0, 0, false)); assertEquals("", Convert.speed(Double.NaN)); assertEquals("Infinity", Convert.speed(Double.POSITIVE_INFINITY)); }