commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chtom...@apache.org
Subject [7/9] [lang] LANG-1252: adding more isNumber Tests before full deletion of method
Date Sun, 11 Sep 2016 17:20:45 GMT
LANG-1252: adding more isNumber Tests before full deletion of method


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/204ed004
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/204ed004
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/204ed004

Branch: refs/heads/master
Commit: 204ed0048f4812201ef65c9a0c44fa54a7d1e04f
Parents: b3c31a3
Author: Rob Tompkins <chtompki@gmail.com>
Authored: Sun Sep 11 11:02:01 2016 -0400
Committer: Rob Tompkins <chtompki@gmail.com>
Committed: Sun Sep 11 11:02:01 2016 -0400

----------------------------------------------------------------------
 .../commons/lang3/math/NumberUtilsTest.java     | 34 ++++++++++++++++++++
 1 file changed, 34 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/204ed004/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
index d9eee43..f9c012f 100644
--- a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
@@ -1376,6 +1376,40 @@ public class NumberUtilsTest {
         compareIsNumberWithCreateNumber("1.1L", false); // LANG-664
     }
 
+    @Test
+    public void testIsNumberLANG971() {
+        compareIsNumberWithCreateNumber("0085", false);
+        compareIsNumberWithCreateNumber("085", false);
+        compareIsNumberWithCreateNumber("08", false);
+        compareIsNumberWithCreateNumber("07", true);
+        compareIsNumberWithCreateNumber("00", true);
+    }
+
+    @Test
+    public void testIsNumberLANG992() {
+        compareIsNumberWithCreateNumber("0.0", true);
+        compareIsNumberWithCreateNumber("0.4790", true);
+    }
+
+    @Test
+    public void testIsNumberLANG972() {
+        compareIsNumberWithCreateNumber("0xABCD", true);
+        compareIsNumberWithCreateNumber("0XABCD", true);
+    }
+
+    @Test
+    public void testIsNumberLANG1252() {
+        //Check idiosyncries between java 1.6 and 1.7,1.8 redarding leading + signs
+        if (SystemUtils.IS_JAVA_1_6) {
+            compareIsNumberWithCreateNumber("+2", false);
+        } else {
+            compareIsNumberWithCreateNumber("+2", true);
+        }
+
+        //The Following should work regardless of 1.6, 1.7, or 1.8
+        compareIsNumberWithCreateNumber("+2.0", true);
+    }
+
     private void compareIsNumberWithCreateNumber(final String val, final boolean expected)
{
         final boolean isValid = NumberUtils.isNumber(val);
         final boolean canCreate = checkCreateNumber(val);


Mime
View raw message