From: PJ Fanning Date: Mon, 1 Jul 2024 23:45:40 +0000 (+0000) Subject: add dataformatter tests X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=648a2e58b079840f42dfc2ed521b7695d4d196d4;p=poi.git add dataformatter tests git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1918807 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/poi/src/test/java/org/apache/poi/ss/usermodel/TestDataFormatter.java b/poi/src/test/java/org/apache/poi/ss/usermodel/TestDataFormatter.java index 8da7e05033..4ef5762ff3 100644 --- a/poi/src/test/java/org/apache/poi/ss/usermodel/TestDataFormatter.java +++ b/poi/src/test/java/org/apache/poi/ss/usermodel/TestDataFormatter.java @@ -110,6 +110,20 @@ class TestDataFormatter { assertFalse(dataFormatter.useCachedValuesForFormulaCells()); } + @Test + void testDouble() { + DataFormatter dfUS = new DataFormatter(Locale.US); + assertEquals("1.005", dfUS.formatRawCellContents(1.005d, -1, "@")); + assertEquals("-1.005", dfUS.formatRawCellContents(-1.005d, -1, "@")); + } + + @Test + void testFloat() { + DataFormatter dfUS = new DataFormatter(Locale.US); + assertEquals("1.005", dfUS.formatRawCellContents(1.005f, -1, "@")); + assertEquals("-1.005", dfUS.formatRawCellContents(-1.005f, -1, "@")); + } + /** * Test that we use the specified locale when deciding * how to format normal numbers @@ -142,7 +156,6 @@ class TestDataFormatter { // Regular numeric style formats assertEquals("63", dfUS.formatRawCellContents(63.0, -1, "[$-1010409]##")); assertEquals("63", dfUS.formatRawCellContents(63.0, -1, "[$-1010409]00")); - }