Renamed stringTo<Type>-metods to to<Type>.
The stringToInt-methods have been deprecated. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137671 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9622df2db9
commit
00731e8e2a
|
@ -71,7 +71,7 @@ import org.apache.commons.lang.StringUtils;
|
||||||
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
|
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
|
||||||
* @author <a href="mailto:fredrik@westermarck.com">Fredrik Westermarck</a>
|
* @author <a href="mailto:fredrik@westermarck.com">Fredrik Westermarck</a>
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
* @version $Id: NumberUtils.java,v 1.14 2003/09/13 03:11:30 psteitz Exp $
|
* @version $Id: NumberUtils.java,v 1.15 2003/09/23 15:46:42 fredrik Exp $
|
||||||
*/
|
*/
|
||||||
public class NumberUtils {
|
public class NumberUtils {
|
||||||
|
|
||||||
|
@ -138,9 +138,31 @@ public class NumberUtils {
|
||||||
* @param str the string to convert, may be null
|
* @param str the string to convert, may be null
|
||||||
* @return the int represented by the string, or <code>zero</code> if
|
* @return the int represented by the string, or <code>zero</code> if
|
||||||
* conversion fails
|
* conversion fails
|
||||||
|
* @deprecated Use {@link #toInt(String)}
|
||||||
|
* This method will be removed in Commons Lang 3.0
|
||||||
*/
|
*/
|
||||||
public static int stringToInt(String str) {
|
public static int stringToInt(String str) {
|
||||||
return stringToInt(str, 0);
|
return toInt(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Convert a <code>String</code> to an <code>int</code>, returning
|
||||||
|
* <code>zero</code> if the conversion fails.</p>
|
||||||
|
*
|
||||||
|
* <p>If the string is <code>null</code>, <code>zero</code> is returned.</p>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* NumberUtils.toInt(null) = 0
|
||||||
|
* NumberUtils.toInt("") = 0
|
||||||
|
* NumberUtils.toInt("1") = 1
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param str the string to convert, may be null
|
||||||
|
* @return the int represented by the string, or <code>zero</code> if
|
||||||
|
* conversion fails
|
||||||
|
*/
|
||||||
|
public static int toInt(String str) {
|
||||||
|
return toInt(str, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -158,8 +180,30 @@ public class NumberUtils {
|
||||||
* @param str the string to convert, may be null
|
* @param str the string to convert, may be null
|
||||||
* @param defaultValue the default value
|
* @param defaultValue the default value
|
||||||
* @return the int represented by the string, or the default if conversion fails
|
* @return the int represented by the string, or the default if conversion fails
|
||||||
|
* @deprecated Use {@link #toInt(String, int)}
|
||||||
|
* This method will be removed in Commons Lang 3.0
|
||||||
*/
|
*/
|
||||||
public static int stringToInt(String str, int defaultValue) {
|
public static int stringToInt(String str, int defaultValue) {
|
||||||
|
return toInt(str, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Convert a <code>String</code> to an <code>int</code>, returning a
|
||||||
|
* default value if the conversion fails.</p>
|
||||||
|
*
|
||||||
|
* <p>If the string is <code>null</code>, the default value is returned.</p>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* NumberUtils.toInt(null, 1) = 1
|
||||||
|
* NumberUtils.toInt("", 1) = 1
|
||||||
|
* NumberUtils.toInt("1", 0) = 1
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param str the string to convert, may be null
|
||||||
|
* @param defaultValue the default value
|
||||||
|
* @return the int represented by the string, or the default if conversion fails
|
||||||
|
*/
|
||||||
|
public static int toInt(String str, int defaultValue) {
|
||||||
try {
|
try {
|
||||||
return Integer.parseInt(str);
|
return Integer.parseInt(str);
|
||||||
} catch (NumberFormatException nfe) {
|
} catch (NumberFormatException nfe) {
|
||||||
|
@ -174,9 +218,9 @@ public class NumberUtils {
|
||||||
* <p>If the string is <code>null</code>, <code>zero</code> is returned.</p>
|
* <p>If the string is <code>null</code>, <code>zero</code> is returned.</p>
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* NumberUtils.stringToLong(null) = 0L
|
* NumberUtils.toLong(null) = 0L
|
||||||
* NumberUtils.stringToLong("") = 0L
|
* NumberUtils.toLong("") = 0L
|
||||||
* NumberUtils.stringToLong("1") = 1L
|
* NumberUtils.toLong("1") = 1L
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param str the string to convert, may be null
|
* @param str the string to convert, may be null
|
||||||
|
@ -184,8 +228,8 @@ public class NumberUtils {
|
||||||
* conversion fails
|
* conversion fails
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public static long stringToLong(String str) {
|
public static long toLong(String str) {
|
||||||
return stringToLong(str, 0L);
|
return toLong(str, 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -195,9 +239,9 @@ public class NumberUtils {
|
||||||
* <p>If the string is <code>null</code>, the default value is returned.</p>
|
* <p>If the string is <code>null</code>, the default value is returned.</p>
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* NumberUtils.stringToLong(null, 1L) = 1L
|
* NumberUtils.toLong(null, 1L) = 1L
|
||||||
* NumberUtils.stringToLong("", 1L) = 1L
|
* NumberUtils.toLong("", 1L) = 1L
|
||||||
* NumberUtils.stringToLong("1", 0L) = 1L
|
* NumberUtils.toLong("1", 0L) = 1L
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param str the string to convert, may be null
|
* @param str the string to convert, may be null
|
||||||
|
@ -205,7 +249,7 @@ public class NumberUtils {
|
||||||
* @return the long represented by the string, or the default if conversion fails
|
* @return the long represented by the string, or the default if conversion fails
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public static long stringToLong(String str, long defaultValue) {
|
public static long toLong(String str, long defaultValue) {
|
||||||
try {
|
try {
|
||||||
return Long.parseLong(str);
|
return Long.parseLong(str);
|
||||||
} catch (NumberFormatException nfe) {
|
} catch (NumberFormatException nfe) {
|
||||||
|
@ -221,9 +265,9 @@ public class NumberUtils {
|
||||||
* <code>0.0f</code> is returned.</p>
|
* <code>0.0f</code> is returned.</p>
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* NumberUtils.stringToFloat(null) = 0.0f
|
* NumberUtils.toFloat(null) = 0.0f
|
||||||
* NumberUtils.stringToFloat("") = 0.0f
|
* NumberUtils.toFloat("") = 0.0f
|
||||||
* NumberUtils.stringToFloat("1.5") = 1.5f
|
* NumberUtils.toFloat("1.5") = 1.5f
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param str the string to convert, may be <code>null</code>
|
* @param str the string to convert, may be <code>null</code>
|
||||||
|
@ -231,8 +275,8 @@ public class NumberUtils {
|
||||||
* if conversion fails
|
* if conversion fails
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public static float stringToFloat(String str) {
|
public static float toFloat(String str) {
|
||||||
return stringToFloat(str, 0.0f);
|
return toFloat(str, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -243,9 +287,9 @@ public class NumberUtils {
|
||||||
* value is returned.</p>
|
* value is returned.</p>
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* NumberUtils.stringToFloat(null, 1.1f) = 1.0f
|
* NumberUtils.toFloat(null, 1.1f) = 1.0f
|
||||||
* NumberUtils.stringToFloat("", 1.1f) = 1.1f
|
* NumberUtils.toFloat("", 1.1f) = 1.1f
|
||||||
* NumberUtils.stringToFloat("1.5", 0.0f) = 1.5f
|
* NumberUtils.toFloat("1.5", 0.0f) = 1.5f
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param str the string to convert, may be <code>null</code>
|
* @param str the string to convert, may be <code>null</code>
|
||||||
|
@ -254,7 +298,7 @@ public class NumberUtils {
|
||||||
* if conversion fails
|
* if conversion fails
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public static float stringToFloat(String str, float defaultValue) {
|
public static float toFloat(String str, float defaultValue) {
|
||||||
if (str == null) {
|
if (str == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
@ -273,9 +317,9 @@ public class NumberUtils {
|
||||||
* <code>0.0d</code> is returned.</p>
|
* <code>0.0d</code> is returned.</p>
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* NumberUtils.stringToDouble(null) = 0.0d
|
* NumberUtils.toDouble(null) = 0.0d
|
||||||
* NumberUtils.stringToDouble("") = 0.0d
|
* NumberUtils.toDouble("") = 0.0d
|
||||||
* NumberUtils.stringToDouble("1.5") = 1.5d
|
* NumberUtils.toDouble("1.5") = 1.5d
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param str the string to convert, may be <code>null</code>
|
* @param str the string to convert, may be <code>null</code>
|
||||||
|
@ -283,8 +327,8 @@ public class NumberUtils {
|
||||||
* if conversion fails
|
* if conversion fails
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public static double stringToDouble(String str) {
|
public static double toDouble(String str) {
|
||||||
return stringToDouble(str, 0.0d);
|
return toDouble(str, 0.0d);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -295,9 +339,9 @@ public class NumberUtils {
|
||||||
* value is returned.</p>
|
* value is returned.</p>
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* NumberUtils.stringToDouble(null, 1.1d) = 1.1d
|
* NumberUtils.toDouble(null, 1.1d) = 1.1d
|
||||||
* NumberUtils.stringToDouble("", 1.1d) = 1.1d
|
* NumberUtils.toDouble("", 1.1d) = 1.1d
|
||||||
* NumberUtils.stringToDouble("1.5", 0.0d) = 1.5d
|
* NumberUtils.toDouble("1.5", 0.0d) = 1.5d
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param str the string to convert, may be <code>null</code>
|
* @param str the string to convert, may be <code>null</code>
|
||||||
|
@ -306,7 +350,7 @@ public class NumberUtils {
|
||||||
* if conversion fails
|
* if conversion fails
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public static double stringToDouble(String str, double defaultValue) {
|
public static double toDouble(String str, double defaultValue) {
|
||||||
if (str == null) {
|
if (str == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ import org.apache.commons.lang.SystemUtils;
|
||||||
* @author Stephen Colebourne
|
* @author Stephen Colebourne
|
||||||
* @author Matthew Hawthorne
|
* @author Matthew Hawthorne
|
||||||
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
|
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
|
||||||
* @version $Id: NumberUtilsTest.java,v 1.9 2003/09/05 15:55:09 psteitz Exp $
|
* @version $Id: NumberUtilsTest.java,v 1.10 2003/09/23 15:46:41 fredrik Exp $
|
||||||
*/
|
*/
|
||||||
public class NumberUtilsTest extends TestCase {
|
public class NumberUtilsTest extends TestCase {
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ public class NumberUtilsTest extends TestCase {
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for int stringToInt(String)
|
* Test for {@link NumberUtils#stringToInt(String)}.
|
||||||
*/
|
*/
|
||||||
public void testStringToIntString() {
|
public void testStringToIntString() {
|
||||||
assertTrue("stringToInt(String) 1 failed", NumberUtils.stringToInt("12345") == 12345);
|
assertTrue("stringToInt(String) 1 failed", NumberUtils.stringToInt("12345") == 12345);
|
||||||
|
@ -116,7 +116,17 @@ public class NumberUtilsTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for int stringToInt(String, int)
|
* Test for {@link NumberUtils#toInt(String)}.
|
||||||
|
*/
|
||||||
|
public void testToIntString() {
|
||||||
|
assertTrue("toInt(String) 1 failed", NumberUtils.toInt("12345") == 12345);
|
||||||
|
assertTrue("toInt(String) 2 failed", NumberUtils.toInt("abc") == 0);
|
||||||
|
assertTrue("toInt(empty) failed", NumberUtils.toInt("") == 0);
|
||||||
|
assertTrue("toInt(null) failed", NumberUtils.toInt(null) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test for {@link NumberUtils#stringToInt(String, int)}.
|
||||||
*/
|
*/
|
||||||
public void testStringToIntStringI() {
|
public void testStringToIntStringI() {
|
||||||
assertTrue("stringToInt(String,int) 1 failed", NumberUtils.stringToInt("12345", 5) == 12345);
|
assertTrue("stringToInt(String,int) 1 failed", NumberUtils.stringToInt("12345", 5) == 12345);
|
||||||
|
@ -124,67 +134,75 @@ public class NumberUtilsTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for long stringToLong(String)
|
* Test for {@link NumberUtils#toInt(String, int)}.
|
||||||
*/
|
*/
|
||||||
public void testStringToLongString() {
|
public void testToIntStringI() {
|
||||||
assertTrue("stringToLong(String) 1 failed", NumberUtils.stringToLong("12345") == 12345l);
|
assertTrue("toInt(String,int) 1 failed", NumberUtils.toInt("12345", 5) == 12345);
|
||||||
assertTrue("stringToLong(String) 2 failed", NumberUtils.stringToLong("abc") == 0l);
|
assertTrue("toInt(String,int) 2 failed", NumberUtils.toInt("1234.5", 5) == 5);
|
||||||
assertTrue("stringToLong(String) 3 failed", NumberUtils.stringToLong("1L") == 0l);
|
|
||||||
assertTrue("stringToLong(String) 4 failed", NumberUtils.stringToLong("1l") == 0l);
|
|
||||||
assertTrue("stringToLong(Long.MAX_VALUE) failed", NumberUtils.stringToLong(Long.MAX_VALUE+"") == Long.MAX_VALUE);
|
|
||||||
assertTrue("stringToLong(Long.MIN_VALUE) failed", NumberUtils.stringToLong(Long.MIN_VALUE+"") == Long.MIN_VALUE);
|
|
||||||
assertTrue("stringToLong(empty) failed", NumberUtils.stringToLong("") == 0l);
|
|
||||||
assertTrue("stringToLong(null) failed", NumberUtils.stringToLong(null) == 0l);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for long stringToLong(String, long)
|
* Test for {@link NumberUtils#toLong(String)}.
|
||||||
*/
|
*/
|
||||||
public void testStringToLongStringL() {
|
public void testToLongString() {
|
||||||
assertTrue("stringToLong(String,long) 1 failed", NumberUtils.stringToLong("12345", 5l) == 12345l);
|
assertTrue("toLong(String) 1 failed", NumberUtils.toLong("12345") == 12345l);
|
||||||
assertTrue("stringToLong(String,long) 2 failed", NumberUtils.stringToLong("1234.5", 5l) == 5l);
|
assertTrue("toLong(String) 2 failed", NumberUtils.toLong("abc") == 0l);
|
||||||
|
assertTrue("toLong(String) 3 failed", NumberUtils.toLong("1L") == 0l);
|
||||||
|
assertTrue("toLong(String) 4 failed", NumberUtils.toLong("1l") == 0l);
|
||||||
|
assertTrue("toLong(Long.MAX_VALUE) failed", NumberUtils.toLong(Long.MAX_VALUE+"") == Long.MAX_VALUE);
|
||||||
|
assertTrue("toLong(Long.MIN_VALUE) failed", NumberUtils.toLong(Long.MIN_VALUE+"") == Long.MIN_VALUE);
|
||||||
|
assertTrue("toLong(empty) failed", NumberUtils.toLong("") == 0l);
|
||||||
|
assertTrue("toLong(null) failed", NumberUtils.toLong(null) == 0l);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for float stringToFloat(String)
|
* Test for {@link NumberUtils#toLong(String, long)}.
|
||||||
*/
|
*/
|
||||||
public void testStringToFloatString() {
|
public void testToLongStringL() {
|
||||||
assertTrue("stringToFloat(String) 1 failed", NumberUtils.stringToFloat("-1.2345") == -1.2345f);
|
assertTrue("toLong(String,long) 1 failed", NumberUtils.toLong("12345", 5l) == 12345l);
|
||||||
assertTrue("stringToFloat(String) 2 failed", NumberUtils.stringToFloat("1.2345") == 1.2345f);
|
assertTrue("toLong(String,long) 2 failed", NumberUtils.toLong("1234.5", 5l) == 5l);
|
||||||
assertTrue("stringToFloat(String) 3 failed", NumberUtils.stringToFloat("abc") == 0.0f);
|
|
||||||
assertTrue("stringToFloat(Float.MAX_VALUE) failed", NumberUtils.stringToFloat(Float.MAX_VALUE+"") == Float.MAX_VALUE);
|
|
||||||
assertTrue("stringToFloat(Float.MIN_VALUE) failed", NumberUtils.stringToFloat(Float.MIN_VALUE+"") == Float.MIN_VALUE);
|
|
||||||
assertTrue("stringToFloat(empty) failed", NumberUtils.stringToFloat("") == 0.0f);
|
|
||||||
assertTrue("stringToFloat(null) failed", NumberUtils.stringToFloat(null) == 0.0f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for float stringToFloat(String, float)
|
* Test for {@link NumberUtils#toFloat(String)}.
|
||||||
*/
|
*/
|
||||||
public void testStringToFloatStringF() {
|
public void testToFloatString() {
|
||||||
assertTrue("stringToFloat(String,int) 1 failed", NumberUtils.stringToFloat("1.2345", 5.1f) == 1.2345f);
|
assertTrue("toFloat(String) 1 failed", NumberUtils.toFloat("-1.2345") == -1.2345f);
|
||||||
assertTrue("stringToFloat(String,int) 2 failed", NumberUtils.stringToFloat("a", 5.0f) == 5.0f);
|
assertTrue("toFloat(String) 2 failed", NumberUtils.toFloat("1.2345") == 1.2345f);
|
||||||
|
assertTrue("toFloat(String) 3 failed", NumberUtils.toFloat("abc") == 0.0f);
|
||||||
|
assertTrue("toFloat(Float.MAX_VALUE) failed", NumberUtils.toFloat(Float.MAX_VALUE+"") == Float.MAX_VALUE);
|
||||||
|
assertTrue("toFloat(Float.MIN_VALUE) failed", NumberUtils.toFloat(Float.MIN_VALUE+"") == Float.MIN_VALUE);
|
||||||
|
assertTrue("toFloat(empty) failed", NumberUtils.toFloat("") == 0.0f);
|
||||||
|
assertTrue("toFloat(null) failed", NumberUtils.toFloat(null) == 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for double stringToDouble(String)
|
* Test for {@link NumberUtils#toFloat(String, float)}.
|
||||||
|
*/
|
||||||
|
public void testToFloatStringF() {
|
||||||
|
assertTrue("toFloat(String,int) 1 failed", NumberUtils.toFloat("1.2345", 5.1f) == 1.2345f);
|
||||||
|
assertTrue("toFloat(String,int) 2 failed", NumberUtils.toFloat("a", 5.0f) == 5.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test for {@link NumberUtils#toDouble(String)}.
|
||||||
*/
|
*/
|
||||||
public void testStringToDoubleString() {
|
public void testStringToDoubleString() {
|
||||||
assertTrue("stringToDouble(String) 1 failed", NumberUtils.stringToDouble("-1.2345") == -1.2345d);
|
assertTrue("toDouble(String) 1 failed", NumberUtils.toDouble("-1.2345") == -1.2345d);
|
||||||
assertTrue("stringToDouble(String) 2 failed", NumberUtils.stringToDouble("1.2345") == 1.2345d);
|
assertTrue("toDouble(String) 2 failed", NumberUtils.toDouble("1.2345") == 1.2345d);
|
||||||
assertTrue("stringToDouble(String) 3 failed", NumberUtils.stringToDouble("abc") == 0.0d);
|
assertTrue("toDouble(String) 3 failed", NumberUtils.toDouble("abc") == 0.0d);
|
||||||
assertTrue("stringToDouble(Double.MAX_VALUE) failed", NumberUtils.stringToDouble(Double.MAX_VALUE+"") == Double.MAX_VALUE);
|
assertTrue("toDouble(Double.MAX_VALUE) failed", NumberUtils.toDouble(Double.MAX_VALUE+"") == Double.MAX_VALUE);
|
||||||
assertTrue("stringToDouble(Double.MIN_VALUE) failed", NumberUtils.stringToDouble(Double.MIN_VALUE+"") == Double.MIN_VALUE);
|
assertTrue("toDouble(Double.MIN_VALUE) failed", NumberUtils.toDouble(Double.MIN_VALUE+"") == Double.MIN_VALUE);
|
||||||
assertTrue("stringToDouble(empty) failed", NumberUtils.stringToDouble("") == 0.0d);
|
assertTrue("toDouble(empty) failed", NumberUtils.toDouble("") == 0.0d);
|
||||||
assertTrue("stringToDouble(null) failed", NumberUtils.stringToDouble(null) == 0.0d);
|
assertTrue("toDouble(null) failed", NumberUtils.toDouble(null) == 0.0d);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for double stringToFloat(String, float)
|
* Test for {@link NumberUtils#toDouble(String, double)}.
|
||||||
*/
|
*/
|
||||||
public void testStringToDoubleStringD() {
|
public void testStringToDoubleStringD() {
|
||||||
assertTrue("stringToDouble(String,int) 1 failed", NumberUtils.stringToDouble("1.2345", 5.1d) == 1.2345d);
|
assertTrue("toDouble(String,int) 1 failed", NumberUtils.toDouble("1.2345", 5.1d) == 1.2345d);
|
||||||
assertTrue("stringToDouble(String,int) 2 failed", NumberUtils.stringToDouble("a", 5.0d) == 5.0d);
|
assertTrue("toDouble(String,int) 2 failed", NumberUtils.toDouble("a", 5.0d) == 5.0d);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateNumber() {
|
public void testCreateNumber() {
|
||||||
|
|
Loading…
Reference in New Issue