}
- // currently disabled because MultiOperandNumericFunction.getNumberArray(Eval[], int, short)
- // does not handle error values properly yet
- public void XtestErrors() {
+ public void testErrors() {
ValueEval[] values = {
new NumberEval(1),
ErrorEval.NAME_INVALID,
ErrorEval.DIV_ZERO,
};
confirmAverage(values, ErrorEval.NAME_INVALID);
-
}
}
package org.apache.poi.hssf.record.formula.functions;
+import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellValue;
/**
* @author Pavel Krupets (pkrupets at palmtreebusiness dot com)
private void confirm(String formulaText, double expectedResult) {
cell11.setCellFormula(formulaText);
evaluator.clearAllCachedResultValues();
- double actualValue = evaluator.evaluate(cell11).getNumberValue();
+ CellValue cv = evaluator.evaluate(cell11);
+ if (cv.getCellType() != Cell.CELL_TYPE_NUMERIC) {
+ throw new AssertionFailedError("Wrong result type: " + cv.formatAsString());
+ }
+ double actualValue = cv.getNumberValue();
assertEquals(expectedResult, actualValue, 0);
}
}
-