add dataformatter test

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1918819 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2024-07-02 09:42:02 +00:00
parent 04c9d0a3c1
commit 6e07ce50dd
3 changed files with 18 additions and 3 deletions

View File

@ -31,6 +31,7 @@ import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.DataFormat;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellReference;
import org.apache.poi.xssf.XSSFITestDataProvider;
@ -160,4 +161,18 @@ public final class TestXSSFDataFormat extends BaseTestDataFormat {
}
}
@Test
public void testGitHub650() throws IOException {
// https://github.com/apache/poi/pull/650
DataFormatter df = new DataFormatter();
try (Workbook wb = _testDataProvider.openSampleWorkbook("decimal-format.xlsx")) {
Sheet sheet = wb.getSheetAt(0);
Cell cell1 = sheet.getRow(0).getCell(0);
assertEquals("1.01", df.formatCellValue(cell1));
Cell cell2 = sheet.getRow(1).getCell(0);
assertEquals("1.00", df.formatCellValue(cell2));
}
}
}

View File

@ -38,7 +38,7 @@ public abstract class BaseTestDataFormat {
protected static final String POUND_FMT = "\"\u00a3\"#,##0;[Red]\\-\"\u00a3\"#,##0";
private final ITestDataProvider _testDataProvider;
protected final ITestDataProvider _testDataProvider;
protected BaseTestDataFormat(ITestDataProvider testDataProvider) {
_testDataProvider = testDataProvider;

Binary file not shown.