Convert { @NonNull public static String glide(double glideRatio, int precision, boolean units) { if (Double.isNaN(glideRatio)) { return ""; } else if (Double.isInfinite(glideRatio) || Math.abs(glideRatio) > 40) { return GLIDE_LEVEL; } else { final String value; if (glideRatio < 0) { value = String.format("+%." + precision + "f", -glideRatio); } else { value = String.format("%." + precision + "f", glideRatio); } if (units) { return value + " : 1"; } else { return value; } } }  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 convertGlide() { assertEquals("0.0", Convert.glide(0.0, 1, false)); assertEquals("0.0 : 1", Convert.glide(0.0, 1, true)); assertEquals("1.0 : 1", Convert.glide(1.0, 1, true)); assertEquals("2.0 : 1", Convert.glide(2.0, 1, true)); assertEquals("+2.0 : 1", Convert.glide(-2.0, 1, true)); assertEquals("2.0", Convert.glide(20, -10, 1, false)); assertEquals("2.0 : 1", Convert.glide(20, -10, 1, true)); assertEquals("+2.0 : 1", Convert.glide(20, 10, 1, true)); assertEquals("", Convert.glide(0, 0, 1, true)); assertEquals("", Convert.glide(Double.NaN, 1, true)); assertEquals("Level", Convert.glide(Double.POSITIVE_INFINITY, 1, true)); assertEquals("Level", Convert.glide(41, 1, true)); assertEquals("Level", Convert.glide(20, 0, 1, true)); assertEquals("Vertical", Convert.glide(0, 10, 1, true)); assertEquals("Stationary", Convert.glide(0.1, 0.1, 1, true)); }