bug 58775: fix a>b which should be a>=b; use shorts instead of ints to hold number format index

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1721923 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2015-12-28 14:19:50 +00:00
parent f3c14d82a6
commit 0849d8c34a

View File

@ -39,16 +39,19 @@ public final class TestXSSFDataFormat extends BaseTestDataFormat {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("49928.xlsx");
doTest49928Core(wb);
// an attempt to register an existing format returns its index
int poundFmtIdx = wb.getSheetAt(0).getRow(0).getCell(0).getCellStyle().getDataFormat();
assertEquals(poundFmtIdx, wb.getStylesSource().putNumberFormat(poundFmt));
DataFormat dataFormat = wb.createDataFormat();
// As of 2015-12-27, there is no way to override a built-in number format with POI XSSFWorkbook
// 49928.xlsx has been saved with a poundFmt that overrides the default value (dollar)
short poundFmtIdx = wb.getSheetAt(0).getRow(0).getCell(0).getCellStyle().getDataFormat();
assertEquals(poundFmtIdx, dataFormat.getFormat(poundFmt));
// now create a custom format with Pound (\u00a3)
DataFormat dataFormat = wb.createDataFormat();
String customFmt = "\u00a3##.00[Yellow]";
assertNotBuiltInFormat(customFmt);
short customFmtIdx = dataFormat.getFormat(customFmt);
assertTrue(customFmtIdx > BuiltinFormats.FIRST_USER_DEFINED_FORMAT_INDEX );
assertTrue(customFmtIdx >= BuiltinFormats.FIRST_USER_DEFINED_FORMAT_INDEX);
assertEquals(customFmt, dataFormat.getFormat(customFmtIdx));
}