add dataformatter tests

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1918807 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2024-07-01 23:45:40 +00:00
parent 96fa957ef5
commit 648a2e58b0
1 changed files with 14 additions and 1 deletions

View File

@ -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"));
}