@Test public void testToFloat_String_float() { System.out.println("toFloat"); float expResult; float result; Properties props = new Properties(); props.put("value1", "12345.6789"); props.put("value2", "-9000.001"); props.put("empty", ""); props.put("str", "abc"); props.put("boolean", "true"); props.put("float", "24.98"); props.put("int", "12"); props.put("char", "a"); PropertyParser instance = new PropertyParser(props); expResult = 12345.6789f; result = instance.toFloat("value1", 0.123f); assertEquals(expResult, result, 0); expResult = -9000.001f; result = instance.toFloat("value2", 0.123f); assertEquals(expResult, result, 0); expResult = 0.123f; result = instance.toFloat("empty", 0.123f); assertEquals(expResult, result, 0); expResult = 0.123f; result = instance.toFloat("str", 0.123f); assertEquals(expResult, result, 0); expResult = 0.123f; result = instance.toFloat("boolean", 0.123f); assertEquals(expResult, result, 0); expResult = 24.98f; result = instance.toFloat("float", 0.123f); assertEquals(expResult, result, 0); expResult = 12; result = instance.toFloat("int", 0.123f); assertEquals(expResult, result, 0); expResult = 0.123f; result = instance.toFloat("char", 0.123f); assertEquals(expResult, result, 0); expResult = 0.123f; result = instance.toFloat("nonexistent", 0.123f); assertEquals(expResult, result, 0); }
public float toFloat(String name) { return toFloat(name, 0.0f); }
PropertyParser { public float toFloat(String name) { return toFloat(name, 0.0f); } }
PropertyParser { public float toFloat(String name) { return toFloat(name, 0.0f); } PropertyParser(Properties properties); }
PropertyParser { public float toFloat(String name) { return toFloat(name, 0.0f); } PropertyParser(Properties properties); Properties getProperties(); void setProperties(Properties properties); String parseString(String name); int parseInt(String name); boolean parseBoolean(String name); float parseFloat(String name); double parseDouble(String name); long parseLong(String name); char parseChar(String name); String toString(String name); int toInt(String name); boolean toBoolean(String name); float toFloat(String name); double toDouble(String name); long toLong(String name); char toChar(String name); String toString(String name, String defaultValue); int toInt(String name, int defaultValue); boolean toBoolean(String name, boolean defaultValue); float toFloat(String name, float defaultValue); double toDouble(String name, double defaultValue); long toLong(String name, long defaultValue); char toChar(String name, char defaultValue); }
PropertyParser { public float toFloat(String name) { return toFloat(name, 0.0f); } PropertyParser(Properties properties); Properties getProperties(); void setProperties(Properties properties); String parseString(String name); int parseInt(String name); boolean parseBoolean(String name); float parseFloat(String name); double parseDouble(String name); long parseLong(String name); char parseChar(String name); String toString(String name); int toInt(String name); boolean toBoolean(String name); float toFloat(String name); double toDouble(String name); long toLong(String name); char toChar(String name); String toString(String name, String defaultValue); int toInt(String name, int defaultValue); boolean toBoolean(String name, boolean defaultValue); float toFloat(String name, float defaultValue); double toDouble(String name, double defaultValue); long toLong(String name, long defaultValue); char toChar(String name, char defaultValue);  }