LANG-1072 Duplicated "0x" check in createBigInteger in NumberUtils

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1643038 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastian Bazley 2014-12-03 01:35:22 +00:00
parent 21201210e2
commit 0162032aa4
3 changed files with 3 additions and 1 deletions

View File

@ -22,6 +22,7 @@
<body>
<release version="3.4" date="tba" description="tba">
<action issue="LANG-1072" type="fix" dev="sebb" due-to="haiyang li">Duplicated "0x" check in createBigInteger in NumberUtils</action>
<action issue="LANG-1064" type="fix" dev="djones" due-to="B.J. Herbison">StringUtils.abbreviate description doesn't agree with the examples</action>
<action issue="LANG-1052" type="add" dev="britter" due-to="Jan Matèrne">Multiline recursive to string style</action>
<action issue="LANG-536" type="add" dev="djones" due-to="James Sawle">Add isSorted() to ArrayUtils</action>

View File

@ -734,7 +734,7 @@ public static BigInteger createBigInteger(final String str) {
negate = true;
pos = 1;
}
if (str.startsWith("0x", pos) || str.startsWith("0x", pos)) { // hex
if (str.startsWith("0x", pos) || str.startsWith("0X", pos)) { // hex
radix = 16;
pos += 2;
} else if (str.startsWith("#", pos)) { // alternative hex (allowed by Long/Integer)

View File

@ -427,6 +427,7 @@ public void testCreateBigInteger() {
// Funky whitespaces
this.testCreateBigIntegerFailure("\u00A0\uFEFF\u000B\u000C\u001C\u001D\u001E\u001F");
assertEquals("createBigInteger(String) failed", new BigInteger("255"), NumberUtils.createBigInteger("0xff"));
assertEquals("createBigInteger(String) failed", new BigInteger("255"), NumberUtils.createBigInteger("0Xff"));
assertEquals("createBigInteger(String) failed", new BigInteger("255"), NumberUtils.createBigInteger("#ff"));
assertEquals("createBigInteger(String) failed", new BigInteger("-255"), NumberUtils.createBigInteger("-0xff"));
assertEquals("createBigInteger(String) failed", new BigInteger("255"), NumberUtils.createBigInteger("0377"));