public void testConvertSharedFormulas() {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFEvaluationWorkbook fpb = HSSFEvaluationWorkbook.create(wb);
Ptg[] sharedFormula, convertedFormula;
SharedFormula sf = new SharedFormula(SpreadsheetVersion.EXCEL97);
sharedFormula = FormulaParser.parse("A2", fpb, FormulaType.CELL, -1);
convertedFormula = sf.convertSharedFormulas(sharedFormula, 0, 0);
confirmOperandClasses(sharedFormula, convertedFormula);
//conversion relative to [0,0] should return the original formula
assertEquals("A2", FormulaRenderer.toFormulaString(fpb, convertedFormula));
convertedFormula = sf.convertSharedFormulas(sharedFormula, 1, 0);
confirmOperandClasses(sharedFormula, convertedFormula);
//one row down
assertEquals("A3", FormulaRenderer.toFormulaString(fpb, convertedFormula));
convertedFormula = sf.convertSharedFormulas(sharedFormula, 1, 1);
confirmOperandClasses(sharedFormula, convertedFormula);
//one row down and one cell right
assertEquals("B3", FormulaRenderer.toFormulaString(fpb, convertedFormula));
sharedFormula = FormulaParser.parse("SUM(A1:C1)", fpb, FormulaType.CELL, -1);
convertedFormula = sf.convertSharedFormulas(sharedFormula, 0, 0);
confirmOperandClasses(sharedFormula, convertedFormula);
assertEquals("SUM(A1:C1)", FormulaRenderer.toFormulaString(fpb, convertedFormula));
convertedFormula = sf.convertSharedFormulas(sharedFormula, 1, 0);
confirmOperandClasses(sharedFormula, convertedFormula);
assertEquals("SUM(A2:C2)", FormulaRenderer.toFormulaString(fpb, convertedFormula));
convertedFormula = sf.convertSharedFormulas(sharedFormula, 1, 1);
confirmOperandClasses(sharedFormula, convertedFormula);
assertEquals("SUM(B2:D2)", FormulaRenderer.toFormulaString(fpb, convertedFormula));
}