use of junit.framework.AssertionFailedError in project poi by apache.
the class TestFormulaParserEval method testEvaluateFormulaWithRowBeyond32768_Bug44539.
public void testEvaluateFormulaWithRowBeyond32768_Bug44539() {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet();
wb.setSheetName(0, "Sheet1");
HSSFRow row = sheet.createRow(0);
HSSFCell cell = row.createCell(0);
cell.setCellFormula("SUM(A32769:A32770)");
// put some values in the cells to make the evaluation more interesting
sheet.createRow(32768).createCell(0).setCellValue(31);
sheet.createRow(32769).createCell(0).setCellValue(11);
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
CellValue result;
try {
result = fe.evaluate(cell);
} catch (FormulaParseException e) {
if (!e.getMessage().equals("Found reference to named range \"A\", but that named range wasn't defined!")) {
throw new AssertionFailedError("Identifed bug 44539");
}
throw e;
}
assertEquals(CellType.NUMERIC, result.getCellTypeEnum());
assertEquals(42.0, result.getNumberValue(), 0.0);
}
use of junit.framework.AssertionFailedError in project poi by apache.
the class TestSheet method testCloneMulBlank_bug46776.
@Test
public void testCloneMulBlank_bug46776() {
Record[] recs = { InternalSheet.createBOF(), new DimensionsRecord(), new RowRecord(1), new MulBlankRecord(1, 3, new short[] { 0x0F, 0x0F, 0x0F }), new RowRecord(2), createWindow2Record(), EOFRecord.instance };
InternalSheet sheet = createSheet(Arrays.asList(recs));
InternalSheet sheet2;
try {
sheet2 = sheet.cloneSheet();
} catch (RuntimeException e) {
if (e.getMessage().equals("The class org.apache.poi.hssf.record.MulBlankRecord needs to define a clone method")) {
throw new AssertionFailedError("Identified bug 46776");
}
throw e;
}
RecordCollector rc = new RecordCollector();
sheet2.visitContainedRecords(rc, 0);
Record[] clonedRecs = rc.getRecords();
// +2 for INDEX and DBCELL
assertEquals(recs.length + 2, clonedRecs.length);
}
use of junit.framework.AssertionFailedError in project poi by apache.
the class TestOperandClassTransformer method testComplexIRR_bug45041.
public void testComplexIRR_bug45041() {
String formula = "(1+IRR(SUMIF(A:A,ROW(INDIRECT(MIN(A:A)&\":\"&MAX(A:A))),B:B),0))^365-1";
Ptg[] ptgs = parseFormula(formula);
FuncVarPtg rowFunc = (FuncVarPtg) ptgs[10];
FuncVarPtg sumifFunc = (FuncVarPtg) ptgs[12];
assertEquals("ROW", rowFunc.getName());
assertEquals("SUMIF", sumifFunc.getName());
if (rowFunc.getPtgClass() == Ptg.CLASS_VALUE || sumifFunc.getPtgClass() == Ptg.CLASS_VALUE) {
throw new AssertionFailedError("Identified bug 45041");
}
confirmTokenClass(ptgs, 1, Ptg.CLASS_REF);
confirmTokenClass(ptgs, 2, Ptg.CLASS_REF);
confirmFuncClass(ptgs, 3, "MIN", Ptg.CLASS_VALUE);
confirmTokenClass(ptgs, 6, Ptg.CLASS_REF);
confirmFuncClass(ptgs, 7, "MAX", Ptg.CLASS_VALUE);
confirmFuncClass(ptgs, 9, "INDIRECT", Ptg.CLASS_REF);
confirmFuncClass(ptgs, 10, "ROW", Ptg.CLASS_ARRAY);
confirmTokenClass(ptgs, 11, Ptg.CLASS_REF);
confirmFuncClass(ptgs, 12, "SUMIF", Ptg.CLASS_ARRAY);
confirmFuncClass(ptgs, 14, "IRR", Ptg.CLASS_VALUE);
}
use of junit.framework.AssertionFailedError in project poi by apache.
the class TestFormulaParserIf method confirmAttrData.
private static void confirmAttrData(Ptg[] ptgs, int i, int expectedData) {
Ptg ptg = ptgs[i];
if (!(ptg instanceof AttrPtg)) {
throw new AssertionFailedError("Token[" + i + "] was not AttrPtg as expected");
}
AttrPtg attrPtg = (AttrPtg) ptg;
assertEquals(expectedData, attrPtg.getData());
}
use of junit.framework.AssertionFailedError in project poi by apache.
the class TestLinkTable method testMultipleExternSheetRecords_bug45698.
public void testMultipleExternSheetRecords_bug45698() {
HSSFWorkbook wb;
try {
wb = HSSFTestDataSamples.openSampleWorkbook("ex45698-22488.xls");
} catch (RuntimeException e) {
if ("Extern sheet is part of LinkTable".equals(e.getMessage())) {
throw new AssertionFailedError("Identified bug 45698");
}
throw e;
}
// some other sanity checks
assertEquals(7, wb.getNumberOfSheets());
}
Aggregations