]> source.dussan.org Git - jackcess.git/commitdiff
more number format unit tests
authorJames Ahlborn <jtahlborn@yahoo.com>
Wed, 6 Jun 2018 02:54:13 +0000 (02:54 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Wed, 6 Jun 2018 02:54:13 +0000 (02:54 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/exprs@1164 f203690c-595d-4dc9-a70b-905162fa7fd2

src/test/java/com/healthmarketscience/jackcess/impl/NumberFormatterTest.java

index ba6fcf0f745058fb77859c2913c0a4fa7169bed6..f69dca1539a5fc4a5cd267c1dd4d2d2db30e0b3d 100644 (file)
@@ -17,6 +17,8 @@ limitations under the License.
 package com.healthmarketscience.jackcess.impl;
 
 
+import java.math.BigDecimal;
+
 import junit.framework.TestCase;
 
 
@@ -84,4 +86,21 @@ public class NumberFormatterTest extends TestCase
     assertEquals("-1.#INF", NumberFormatter.format(Float.NEGATIVE_INFINITY));
     assertEquals("1.#QNAN", NumberFormatter.format(Float.NaN));
   }
+
+  public void testDecimalFormat() throws Exception
+  {
+    assertEquals("9874539485972.2342342234234", NumberFormatter.format(new BigDecimal("9874539485972.2342342234234")));
+    assertEquals("9874539485972.234234223423468", NumberFormatter.format(new BigDecimal("9874539485972.2342342234234678")));
+    assertEquals("-9874539485972.234234223423468", NumberFormatter.format(new BigDecimal("-9874539485972.2342342234234678")));
+    assertEquals("9.874539485972234234223423468E+31", NumberFormatter.format(new BigDecimal("98745394859722342342234234678000")));
+    assertEquals("9.874539485972234234223423468E+31", NumberFormatter.format(new BigDecimal("98745394859722342342234234678000")));
+    assertEquals("-9.874539485972234234223423468E+31", NumberFormatter.format(new BigDecimal("-98745394859722342342234234678000")));
+    assertEquals("300", NumberFormatter.format(new BigDecimal("300.0")));
+    assertEquals("-300", NumberFormatter.format(new BigDecimal("-300.000")));
+    assertEquals("0.3", NumberFormatter.format(new BigDecimal("0.3")));
+    assertEquals("0.1", NumberFormatter.format(new BigDecimal("0.1000")));
+    assertEquals("0.0000000000023423428930458", NumberFormatter.format(new BigDecimal("0.0000000000023423428930458")));
+    assertEquals("2.3423428930458389038451E-12", NumberFormatter.format(new BigDecimal("0.0000000000023423428930458389038451")));
+    assertEquals("2.342342893045838903845134766E-12", NumberFormatter.format(new BigDecimal("0.0000000000023423428930458389038451347656")));
+  }
 }