Add unit test to verify that bug #47490 no longer exists

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@951446 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2010-06-04 15:33:47 +00:00
parent 80ff41d36a
commit 74c40ef943
1 changed files with 33 additions and 0 deletions

View File

@ -26,6 +26,7 @@ import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackagingURIHelper;
import org.apache.poi.ss.usermodel.BaseTestBugzillaIssues;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.Name;
import org.apache.poi.ss.usermodel.Row;
@ -297,4 +298,36 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
assertEquals(startingFonts+3, wb.getNumberOfFonts());
}
}
/**
* Ensure General and @ format are working properly
* for integers
*/
public void test47490() throws Exception {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("GeneralFormatTests.xlsx");
Sheet s = wb.getSheetAt(1);
Row r;
DataFormatter df = new DataFormatter();
r = s.getRow(1);
assertEquals(1.0, r.getCell(2).getNumericCellValue());
assertEquals("General", r.getCell(2).getCellStyle().getDataFormatString());
assertEquals("1", df.formatCellValue(r.getCell(2)));
assertEquals("1", df.formatRawCellContents(1.0, -1, "@"));
assertEquals("1", df.formatRawCellContents(1.0, -1, "General"));
r = s.getRow(2);
assertEquals(12.0, r.getCell(2).getNumericCellValue());
assertEquals("General", r.getCell(2).getCellStyle().getDataFormatString());
assertEquals("12", df.formatCellValue(r.getCell(2)));
assertEquals("12", df.formatRawCellContents(12.0, -1, "@"));
assertEquals("12", df.formatRawCellContents(12.0, -1, "General"));
r = s.getRow(3);
assertEquals(123.0, r.getCell(2).getNumericCellValue());
assertEquals("General", r.getCell(2).getCellStyle().getDataFormatString());
assertEquals("123", df.formatCellValue(r.getCell(2)));
assertEquals("123", df.formatRawCellContents(123.0, -1, "@"));
assertEquals("123", df.formatRawCellContents(123.0, -1, "General"));
}
}