From: Nick Burch Date: Fri, 4 Jun 2010 15:33:47 +0000 (+0000) Subject: Add unit test to verify that bug #47490 no longer exists X-Git-Tag: REL_3_7_BETA1~18 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=40b7db249f5262a221a6fe9f626ebe0085099b17;p=poi.git 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 --- diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index 5cb25243d7..ed8f03e784 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -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")); + } }