From 433933ab0b1a4b6b654d41d42067f4ef042ae471 Mon Sep 17 00:00:00 2001 From: Josh Micich Date: Sun, 22 Nov 2009 22:39:00 +0000 Subject: [PATCH] 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 --- .../poi/hssf/record/formula/functions/TestAverage.java | 5 +---- .../poi/hssf/record/formula/functions/TestDate.java | 10 ++++++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/testcases/org/apache/poi/hssf/record/formula/functions/TestAverage.java b/src/testcases/org/apache/poi/hssf/record/formula/functions/TestAverage.java index e14c1db951..5b772bb0c1 100644 --- a/src/testcases/org/apache/poi/hssf/record/formula/functions/TestAverage.java +++ b/src/testcases/org/apache/poi/hssf/record/formula/functions/TestAverage.java @@ -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); - } } diff --git a/src/testcases/org/apache/poi/hssf/record/formula/functions/TestDate.java b/src/testcases/org/apache/poi/hssf/record/formula/functions/TestDate.java index b93eb7a6c7..eac8bfd113 100644 --- a/src/testcases/org/apache/poi/hssf/record/formula/functions/TestDate.java +++ b/src/testcases/org/apache/poi/hssf/record/formula/functions/TestDate.java @@ -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); } } - -- 2.39.5