mirror of https://github.com/apache/poi.git
Continue with 55747 / 55324 testing
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1695603 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
997eabb9fe
commit
5e8a6d7fdf
|
@ -417,7 +417,8 @@ public final class TestFormulaEvaluatorBugs extends TestCase {
|
||||||
assertEquals(ErrorEval.NA, ve);
|
assertEquals(ErrorEval.NA, ve);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void test55747_55324() throws Exception {
|
@SuppressWarnings("resource")
|
||||||
|
public void test55747_55324() throws Exception {
|
||||||
HSSFWorkbook wb = new HSSFWorkbook();
|
HSSFWorkbook wb = new HSSFWorkbook();
|
||||||
HSSFFormulaEvaluator ev = wb.getCreationHelper().createFormulaEvaluator();
|
HSSFFormulaEvaluator ev = wb.getCreationHelper().createFormulaEvaluator();
|
||||||
HSSFSheet ws = wb.createSheet();
|
HSSFSheet ws = wb.createSheet();
|
||||||
|
@ -464,7 +465,12 @@ public final class TestFormulaEvaluatorBugs extends TestCase {
|
||||||
// Evaluate
|
// Evaluate
|
||||||
ev.evaluateAll();
|
ev.evaluateAll();
|
||||||
|
|
||||||
// Check the MID Ptgs have V RefPtgs for A1
|
// Save and re-load
|
||||||
|
wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
|
||||||
|
ws = wb.getSheetAt(0);
|
||||||
|
|
||||||
|
// Check the MID Ptgs in Row 2 have V RefPtgs for A1
|
||||||
|
row = ws.getRow(1);
|
||||||
for (int i=1; i<=4; i++) {
|
for (int i=1; i<=4; i++) {
|
||||||
cell = row.getCell(i);
|
cell = row.getCell(i);
|
||||||
Ptg[] ptgs = getPtgs(cell);
|
Ptg[] ptgs = getPtgs(cell);
|
||||||
|
@ -479,33 +485,55 @@ public final class TestFormulaEvaluatorBugs extends TestCase {
|
||||||
|
|
||||||
// H1, MID is used in the expression IF checks, so A1 should be V
|
// H1, MID is used in the expression IF checks, so A1 should be V
|
||||||
cell = row.getCell(CellReference.convertColStringToIndex("H"));
|
cell = row.getCell(CellReference.convertColStringToIndex("H"));
|
||||||
|
assertRefPtgA1('V', getPtgs(cell), 0);
|
||||||
|
|
||||||
// E1, MID is used in the FALSE route, so A1 should be V
|
// E1, MID is used in the FALSE route, so:
|
||||||
|
// A1 should be V in the IF check
|
||||||
|
// A1 should be R in the FALSE route
|
||||||
|
cell = row.getCell(CellReference.convertColStringToIndex("E"));
|
||||||
|
assertRefPtgA1('V', getPtgs(cell), 0);
|
||||||
|
assertRefPtgA1('R', getPtgs(cell), 6);
|
||||||
|
|
||||||
//
|
// Check that, for B1, D1, F1 and G1, the references to A1
|
||||||
|
// from all of IF check, True and False are V
|
||||||
|
cell = row.getCell(CellReference.convertColStringToIndex("B"));
|
||||||
|
assertRefPtgA1('V', getPtgs(cell), 0);
|
||||||
|
// assertRefPtgA1('V', getPtgs(cell), 4); // FIXME!
|
||||||
|
|
||||||
// Check that, for E1 and H1, the A1 in the IF is a V, but in the
|
cell = row.getCell(CellReference.convertColStringToIndex("D"));
|
||||||
// True -> MID is an R
|
assertRefPtgA1('V', getPtgs(cell), 0);
|
||||||
for (int cn : new int[] { 4, 7 }) {
|
// assertRefPtgA1('V', getPtgs(cell), 6); // FIXME!
|
||||||
cell = row.getCell(cn);
|
|
||||||
|
|
||||||
FormulaRecordAggregate agg = (FormulaRecordAggregate)cell.getCellValueRecord();
|
|
||||||
FormulaRecord rec = agg.getFormulaRecord();
|
|
||||||
|
|
||||||
// 1st is the
|
|
||||||
assertEquals(RefPtg.class, rec.getParsedExpression()[0].getClass());
|
|
||||||
assertEquals('V', ((RefPtg)rec.getParsedExpression()[0]).getRVAType());
|
|
||||||
assertEquals(0, ((RefPtg)rec.getParsedExpression()[0]).getRow());
|
|
||||||
assertEquals(0, ((RefPtg)rec.getParsedExpression()[0]).getColumn());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check that, for B1, D1, F1 and G1
|
cell = row.getCell(CellReference.convertColStringToIndex("F"));
|
||||||
|
assertRefPtgA1('V', getPtgs(cell), 0);
|
||||||
|
// assertRefPtgA1('V', getPtgs(cell), 4); // FIXME!
|
||||||
|
// assertRefPtgA1('V', getPtgs(cell), 9); // FIXME!
|
||||||
|
|
||||||
// Check our values
|
cell = row.getCell(CellReference.convertColStringToIndex("G"));
|
||||||
// TODO
|
assertRefPtgA1('V', getPtgs(cell), 0);
|
||||||
|
// assertRefPtgA1('V', getPtgs(cell), 4); // FIXME!
|
||||||
|
// assertRefPtgA1('V', getPtgs(cell), 9); // FIXME!
|
||||||
|
|
||||||
// Check our PTGs
|
|
||||||
// TODO
|
// Check our cached values were correctly evaluated
|
||||||
|
cell = row.getCell(CellReference.convertColStringToIndex("A"));
|
||||||
|
assertEquals("abc", cell.getStringCellValue());
|
||||||
|
cell = row.getCell(CellReference.convertColStringToIndex("B"));
|
||||||
|
assertEquals("ab", cell.getStringCellValue());
|
||||||
|
cell = row.getCell(CellReference.convertColStringToIndex("C"));
|
||||||
|
assertEquals("A", cell.getStringCellValue());
|
||||||
|
cell = row.getCell(CellReference.convertColStringToIndex("D"));
|
||||||
|
assertEquals("ab", cell.getStringCellValue());
|
||||||
|
cell = row.getCell(CellReference.convertColStringToIndex("E"));
|
||||||
|
assertEquals("X", cell.getStringCellValue());
|
||||||
|
cell = row.getCell(CellReference.convertColStringToIndex("F"));
|
||||||
|
assertEquals("bc", cell.getStringCellValue());
|
||||||
|
cell = row.getCell(CellReference.convertColStringToIndex("G"));
|
||||||
|
assertEquals("ab", cell.getStringCellValue());
|
||||||
|
cell = row.getCell(CellReference.convertColStringToIndex("H"));
|
||||||
|
assertEquals("A", cell.getStringCellValue());
|
||||||
|
|
||||||
|
// Enable this block to write out, and check in Excel
|
||||||
//FileOutputStream out = new FileOutputStream("/tmp/test.xls");
|
//FileOutputStream out = new FileOutputStream("/tmp/test.xls");
|
||||||
//wb.write(out);
|
//wb.write(out);
|
||||||
//out.close();
|
//out.close();
|
||||||
|
@ -520,8 +548,8 @@ public final class TestFormulaEvaluatorBugs extends TestCase {
|
||||||
private void assertRefPtgA1(char rv, Ptg[] ptgs, int at) {
|
private void assertRefPtgA1(char rv, Ptg[] ptgs, int at) {
|
||||||
Ptg ptg = ptgs[at];
|
Ptg ptg = ptgs[at];
|
||||||
assertEquals(RefPtg.class, ptg.getClass());
|
assertEquals(RefPtg.class, ptg.getClass());
|
||||||
assertEquals(0, ((RefPtg)ptg).getRow());
|
assertEquals(0, ((RefPtg)ptg).getRow());
|
||||||
assertEquals(0, ((RefPtg)ptg).getColumn());
|
assertEquals(0, ((RefPtg)ptg).getColumn());
|
||||||
assertEquals('V', ((RefPtg)ptg).getRVAType());
|
assertEquals(rv, ((RefPtg)ptg).getRVAType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue