added extra RVA test case (for bug 45206)

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@668014 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Josh Micich 2008-06-15 22:26:06 +00:00
parent e1de21bc09
commit 473ac7ad05
3 changed files with 17 additions and 16 deletions

View File

@ -15,11 +15,10 @@
limitations under the License.
==================================================================== */
package org.apache.poi.hssf.record.formula;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.CellReference;
import org.apache.poi.hssf.util.RangeAddress;
import org.apache.poi.hssf.util.SheetReferences;
@ -69,16 +68,15 @@ public class Ref3DPtg extends OperandPtg {
}
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append("Ref3dPtg\n");
buffer.append("Index to Extern Sheet = " + getExternSheetIndex()).append("\n");
buffer.append("Row = " + getRow()).append("\n");
buffer.append("Col = " + getColumn()).append("\n");
buffer.append("ColRowRel= "
+ isRowRelative()).append("\n");
buffer.append("ColRel = " + isColRelative()).append("\n");
return buffer.toString();
CellReference cr = new CellReference(getRow(), getColumn(), !isRowRelative(),!isColRelative());
StringBuffer sb = new StringBuffer();
sb.append(getClass().getName());
sb.append(" [");
sb.append("sheetIx=").append(getExternSheetIndex());
sb.append(" ! ");
sb.append(cr.formatAsString());
sb.append("]");
return sb.toString();
}
public void writeBytes(byte [] array, int offset) {

View File

@ -23,7 +23,6 @@ import junit.framework.TestCase;
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.record.formula.AttrPtg;
import org.apache.poi.hssf.record.formula.Ptg;
import org.apache.poi.hssf.record.formula.RefPtgBase;
import org.apache.poi.hssf.usermodel.FormulaExtractor;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
@ -60,7 +59,7 @@ public final class TestRVA extends TestCase {
}
String formula = cell.getCellFormula();
try {
confirmCell(cell, formula);
confirmCell(cell, formula, wb);
} catch (AssertionFailedError e) {
System.err.println("Problem with row[" + rowIx + "] formula '" + formula + "'");
System.err.println(e.getMessage());
@ -79,9 +78,9 @@ public final class TestRVA extends TestCase {
}
}
private void confirmCell(HSSFCell formulaCell, String formula) {
private void confirmCell(HSSFCell formulaCell, String formula, HSSFWorkbook wb) {
Ptg[] excelPtgs = FormulaExtractor.getPtgs(formulaCell);
Ptg[] poiPtgs = FormulaParser.parse(formula, null);
Ptg[] poiPtgs = FormulaParser.parse(formula, wb);
int nExcelTokens = excelPtgs.length;
int nPoiTokens = poiPtgs.length;
if (nExcelTokens != nPoiTokens) {
@ -122,6 +121,10 @@ public final class TestRVA extends TestCase {
}
sb.append(NEW_LINE);
}
if (false) { // set 'true' to see trace of RVA values
System.out.println(formula);
System.out.println(sb.toString());
}
if (hasMismatch) {
throw new AssertionFailedError(sb.toString());
}