ParsingUtils { public static double convertToDouble(final String val) { return convertToDouble(val, 0); }  static boolean convertToBoolean(final String str, final boolean defaultValueIsTrue); static boolean convertToBoolean(final String val); static int convertToInt(final String val); static int convertToInt(final String val, final int defaultValue); static long convertToLong(final String val); static long convertToLong(final String val, final int defaultValue); static long convertToLong(final String val, final long defaultValue); static double convertToDouble(final String val); static double convertToDouble(final String val, final double defaultValue); static long convertToCapacity(
      final String str,
      final long defaultValue); static long convertToTime(final String val); static long parse(
      final String val,
      final TimeUnit unit); static final List<ScaleUnit> INTERVALS; }
@Test public void testConvertToDouble() { final Object[][] testParameters = new Object[][] {{"1.1", 1.1}, {"10.21", 10.21}, {"100.321", 100.321}, {"Not", 0.0}}; for (final Object[] testParameter : testParameters) { double expected = (Double) testParameter[1]; String val = (String) testParameter[0]; assertEquals(expected, ParsingUtils.convertToDouble(val), 1e-15); } }
@Test public void testConvertToDoubleOnDefaultValue() { final Object[][] testParameters = new Object[][] {{"1.1", 0.0, 1.1}, {"10.21", 1.0, 10.21}, {"100.321", 2.0, 100.321}, {"Not01", 0.0, 0.0}, {"Not02", 1.0, 1.0}, {"Not03", 2.0, 2.0}}; assertEquals(0.0, ParsingUtils.convertToDouble(null, 0.0), 1e-15); assertEquals(1.0, ParsingUtils.convertToDouble(null, 1.0), 1e-15); for (final Object[] testParameter : testParameters) { double expected = (Double) testParameter[2]; String val = (String) testParameter[0]; double defaultValue = (Double) testParameter[1]; assertEquals(expected, ParsingUtils.convertToDouble(val, defaultValue), 1e-15); } }