From 0b5f764325222755fc82190b3481a0637d23cbed Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Wed, 6 Jun 2018 02:54:13 +0000 Subject: more number format unit tests git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/exprs@1164 f203690c-595d-4dc9-a70b-905162fa7fd2 --- .../jackcess/impl/NumberFormatterTest.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/test/java/com/healthmarketscience/jackcess/impl/NumberFormatterTest.java b/src/test/java/com/healthmarketscience/jackcess/impl/NumberFormatterTest.java index ba6fcf0..f69dca1 100644 --- a/src/test/java/com/healthmarketscience/jackcess/impl/NumberFormatterTest.java +++ b/src/test/java/com/healthmarketscience/jackcess/impl/NumberFormatterTest.java @@ -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"))); + } } -- cgit v1.2.3