mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
Add test which populates cells with null string
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1925187 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7c9a1ce89b
commit
85aa74414c
@ -1473,6 +1473,36 @@ public abstract class BaseTestCell {
|
||||
verify(cell).setBlank();
|
||||
}
|
||||
|
||||
@Test
|
||||
protected void setCellNullString() throws IOException {
|
||||
try (Workbook wb = _testDataProvider.createWorkbook()) {
|
||||
Cell cell = getInstance(wb);
|
||||
|
||||
cell.setCellValue((String)null);
|
||||
|
||||
// setting string "null" leads to a BLANK cell
|
||||
assertEquals(CellType.BLANK, cell.getCellType());
|
||||
assertEquals("", cell.getStringCellValue());
|
||||
assertEquals("", cell.toString());
|
||||
|
||||
cell.setCellType(CellType.STRING);
|
||||
|
||||
// forcing to string type leads to STRING cell, but still empty strings
|
||||
assertEquals(CellType.STRING, cell.getCellType());
|
||||
assertEquals("", cell.getStringCellValue());
|
||||
assertEquals("", cell.toString());
|
||||
|
||||
try (Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb)) {
|
||||
// read first sheet, first row, first cell
|
||||
Cell cellBack = wb2.iterator().next().iterator().next().iterator().next();
|
||||
|
||||
assertEquals(CellType.STRING, cell.getCellType());
|
||||
assertEquals("", cell.getStringCellValue());
|
||||
assertEquals("", cell.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Cell getInstance(Workbook wb) {
|
||||
return wb.createSheet().createRow(0).createCell(0);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user