From 1e3ecfff20e58b1a25fa4c5f23ac79efe353df1a Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Sun, 31 Jul 2005 23:55:24 +0000 Subject: [PATCH] Slightly better unit test code coverage. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@226704 13f79535-47bb-0310-9956-ffa450edef68 --- .../commons/lang/math/NumberUtilsTest.java | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/test/org/apache/commons/lang/math/NumberUtilsTest.java b/src/test/org/apache/commons/lang/math/NumberUtilsTest.java index 16dbe444a..0116c2d3d 100644 --- a/src/test/org/apache/commons/lang/math/NumberUtilsTest.java +++ b/src/test/org/apache/commons/lang/math/NumberUtilsTest.java @@ -167,14 +167,15 @@ public class NumberUtilsTest extends TestCase { } public void testCreateNumber() { - //a lot of things can go wrong + // a lot of things can go wrong assertEquals("createNumber(String) 1 failed", new Float("1234.5"), NumberUtils.createNumber("1234.5")); assertEquals("createNumber(String) 2 failed", new Integer("12345"), NumberUtils.createNumber("12345")); assertEquals("createNumber(String) 3 failed", new Double("1234.5"), NumberUtils.createNumber("1234.5D")); assertEquals("createNumber(String) 3 failed", new Double("1234.5"), NumberUtils.createNumber("1234.5d")); assertEquals("createNumber(String) 4 failed", new Float("1234.5"), NumberUtils.createNumber("1234.5F")); assertEquals("createNumber(String) 4 failed", new Float("1234.5"), NumberUtils.createNumber("1234.5f")); - assertEquals("createNumber(String) 5 failed", new Long(Integer.MAX_VALUE + 1L), NumberUtils.createNumber("" + (Integer.MAX_VALUE + 1L))); + assertEquals("createNumber(String) 5 failed", new Long(Integer.MAX_VALUE + 1L), NumberUtils.createNumber("" + + (Integer.MAX_VALUE + 1L))); assertEquals("createNumber(String) 6 failed", new Long(12345), NumberUtils.createNumber("12345L")); assertEquals("createNumber(String) 6 failed", new Long(12345), NumberUtils.createNumber("12345l")); assertEquals("createNumber(String) 7 failed", new Float("-1234.5"), NumberUtils.createNumber("-1234.5")); @@ -186,24 +187,20 @@ public class NumberUtilsTest extends TestCase { assertEquals("createNumber(String) 13 failed", new Double("-1.1E200"), NumberUtils.createNumber("-1.1E200")); assertEquals("createNumber(String) 14 failed", new Double("1.1E-200"), NumberUtils.createNumber("1.1E-200")); assertEquals("createNumber(null) failed", null, NumberUtils.createNumber(null)); - - // jdk 1.2 doesn't support this. unsure about jdk 1.2.2 - if(SystemUtils.isJavaVersionAtLeast(1.3f)) { - assertEquals("createNumber(String) 15 failed", new BigDecimal("1.1E-700"), NumberUtils.createNumber("1.1E-700F")); - } - assertEquals( - "createNumber(String) 16 failed", - new Long("10" + Integer.MAX_VALUE), - NumberUtils.createNumber("10" + Integer.MAX_VALUE + "L")); - assertEquals( - "createNumber(String) 17 failed", - new Long("10" + Integer.MAX_VALUE), - NumberUtils.createNumber("10" + Integer.MAX_VALUE)); - assertEquals( - "createNumber(String) 18 failed", - new BigInteger("10" + Long.MAX_VALUE), - NumberUtils.createNumber("10" + Long.MAX_VALUE)); + assertEquals("createNumber(String) failed", new BigInteger("12345678901234567890"), NumberUtils + .createNumber("12345678901234567890L")); + // jdk 1.2 doesn't support this. unsure about jdk 1.2.2 + if (SystemUtils.isJavaVersionAtLeast(1.3f)) { + assertEquals("createNumber(String) 15 failed", new BigDecimal("1.1E-700"), NumberUtils + .createNumber("1.1E-700F")); + } + assertEquals("createNumber(String) 16 failed", new Long("10" + Integer.MAX_VALUE), NumberUtils + .createNumber("10" + Integer.MAX_VALUE + "L")); + assertEquals("createNumber(String) 17 failed", new Long("10" + Integer.MAX_VALUE), NumberUtils + .createNumber("10" + Integer.MAX_VALUE)); + assertEquals("createNumber(String) 18 failed", new BigInteger("10" + Long.MAX_VALUE), NumberUtils + .createNumber("10" + Long.MAX_VALUE)); } public void testCreateFloat() {