@Test public void testConvertMile() { double mi = 1.0; double mm = 1609344; double cm = 160934.4; double dm = 16093.44; double m = 1609.344; double dam = 160.9344; double hm = 16.09344; double km = 1.609344; double in = 63360.0; double ft = 5280.0; double yd = 1760.0; double nm = 0.868976241900648; double ly = 1.7010779502325107E-13; ConvertDistances converter0 = new ConvertDistances(ConvertDistances.Distance.MILE, ConvertDistances.Distance.MILE); Assert.assertEquals(mi, converter0.convert(mi), delta); ConvertDistances converter1 = new ConvertDistances(ConvertDistances.Distance.MILE, ConvertDistances.Distance.MILLIMETER); Assert.assertEquals(mm, converter1.convert(mi), delta); ConvertDistances converter2 = new ConvertDistances(ConvertDistances.Distance.MILE, ConvertDistances.Distance.CENTIMETER); Assert.assertEquals(cm, converter2.convert(mi), delta); ConvertDistances converter3 = new ConvertDistances(ConvertDistances.Distance.MILE, ConvertDistances.Distance.DECIMETER); Assert.assertEquals(dm, converter3.convert(mi), delta); ConvertDistances converter4 = new ConvertDistances(ConvertDistances.Distance.MILE, ConvertDistances.Distance.METER); Assert.assertEquals(m, converter4.convert(mi), delta); ConvertDistances converter5 = new ConvertDistances(ConvertDistances.Distance.MILE, ConvertDistances.Distance.HECTOMETER); Assert.assertEquals(hm, converter5.convert(mi), delta); ConvertDistances converter6 = new ConvertDistances(ConvertDistances.Distance.MILE, ConvertDistances.Distance.DEKAMETER); Assert.assertEquals(dam, converter6.convert(mi), delta); ConvertDistances converter7 = new ConvertDistances(ConvertDistances.Distance.MILE, ConvertDistances.Distance.KILOMETER); Assert.assertEquals(km, converter7.convert(mi), delta); ConvertDistances converter8 = new ConvertDistances(ConvertDistances.Distance.MILE, ConvertDistances.Distance.INCH); Assert.assertEquals(in, converter8.convert(mi), delta); ConvertDistances converter9 = new ConvertDistances(ConvertDistances.Distance.MILE, ConvertDistances.Distance.FOOT); Assert.assertEquals(ft, converter9.convert(mi), delta); ConvertDistances converter10 = new ConvertDistances(ConvertDistances.Distance.MILE, ConvertDistances.Distance.YARD); Assert.assertEquals(yd, converter10.convert(mi), delta); ConvertDistances converter11 = new ConvertDistances(ConvertDistances.Distance.MILE, ConvertDistances.Distance.NAUTICAL_MILE); Assert.assertEquals(nm, converter11.convert(mi), delta); ConvertDistances converter12 = new ConvertDistances(ConvertDistances.Distance.MILE, ConvertDistances.Distance.LIGHT_YEAR); Assert.assertEquals(ly, converter12.convert(mi), delta); }
public double convert(double value) { if (Double.isNaN(value)) { return value; } if (from.equals(to)) { return value; } BigDecimal result = new BigDecimal(String.valueOf(value)).multiply(multiplier); return result.doubleValue(); }
ConvertDistances { public double convert(double value) { if (Double.isNaN(value)) { return value; } if (from.equals(to)) { return value; } BigDecimal result = new BigDecimal(String.valueOf(value)).multiply(multiplier); return result.doubleValue(); } }
ConvertDistances { public double convert(double value) { if (Double.isNaN(value)) { return value; } if (from.equals(to)) { return value; } BigDecimal result = new BigDecimal(String.valueOf(value)).multiply(multiplier); return result.doubleValue(); } ConvertDistances(); @Nullable  ConvertDistances(Distance from, Distance to); }
ConvertDistances { public double convert(double value) { if (Double.isNaN(value)) { return value; } if (from.equals(to)) { return value; } BigDecimal result = new BigDecimal(String.valueOf(value)).multiply(multiplier); return result.doubleValue(); } ConvertDistances(); @Nullable  ConvertDistances(Distance from, Distance to); double convert(double value); }
ConvertDistances { public double convert(double value) { if (Double.isNaN(value)) { return value; } if (from.equals(to)) { return value; } BigDecimal result = new BigDecimal(String.valueOf(value)).multiply(multiplier); return result.doubleValue(); } ConvertDistances(); @Nullable  ConvertDistances(Distance from, Distance to); double convert(double value);  }