]> source.dussan.org Git - poi.git/commitdiff
small tweaks to junit code - enabled one test case for AVERAGE() and improved diagnos...
authorJosh Micich <josh@apache.org>
Sun, 22 Nov 2009 22:39:00 +0000 (22:39 +0000)
committerJosh Micich <josh@apache.org>
Sun, 22 Nov 2009 22:39:00 +0000 (22:39 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@883167 13f79535-47bb-0310-9956-ffa450edef68

src/testcases/org/apache/poi/hssf/record/formula/functions/TestAverage.java
src/testcases/org/apache/poi/hssf/record/formula/functions/TestDate.java

index e14c1db9515693071bdc2c47c968e226d1db553e..5b772bb0c18db364dc8446523916098b29318453 100644 (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);
-
        }
 }
index b93eb7a6c705736e8173fa9c5b8348ef838c5f4b..eac8bfd11331285e3af6b8d6581d1e1e343a3b49 100644 (file)
 
 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);
     }
 }
-