small tweaks to junit code - enabled one test case for AVERAGE() and improved diagnostics in TestDate

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@883167 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Josh Micich 2009-11-22 22:39:00 +00:00
parent 6be8ae88fc
commit 24717007c8
2 changed files with 9 additions and 6 deletions

View File

@ -86,9 +86,7 @@ public final class TestAverage extends TestCase {
}
// 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,
@ -96,6 +94,5 @@ public final class TestAverage extends TestCase {
ErrorEval.DIV_ZERO,
};
confirmAverage(values, ErrorEval.NAME_INVALID);
}
}

View File

@ -17,12 +17,15 @@
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)
@ -77,8 +80,11 @@ public final class TestDate extends TestCase {
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);
}
}