Bug 55037: patch for missing function DELTA

Add missing TestDeltaFunctionsFromSpreadsheet and register Delta in AnalysisToolPak

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1529809 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Cédric Walter 2013-10-07 09:42:38 +00:00
parent 927dc0ce1d
commit 805d583bab
4 changed files with 25 additions and 2 deletions

View File

@ -91,7 +91,7 @@ public final class AnalysisToolPak implements UDFFinder {
r(m, "DEC2BIN", null);
r(m, "DEC2HEX", null);
r(m, "DEC2OCT", null);
r(m, "DELTA", null);
r(m, "DELTA", Delta.instance);
r(m, "DISC", null);
r(m, "DOLLARDE", null);
r(m, "DOLLARFR", null);

View File

@ -17,6 +17,7 @@
package org.apache.poi.ss.formula.functions;
import org.apache.poi.ss.formula.OperationEvaluationContext;
import org.apache.poi.ss.formula.eval.*;
import java.math.BigDecimal;
@ -37,7 +38,9 @@ import java.math.BigDecimal;
*
* @author cedric dot walter @ gmail dot com
*/
public final class Delta extends Fixed2ArgFunction {
public final class Delta extends Fixed2ArgFunction implements FreeRefFunction {
public static final FreeRefFunction instance = new Delta();
private final static NumberEval ONE = new NumberEval(1);
private final static NumberEval ZERO = new NumberEval(0);
@ -72,4 +75,11 @@ public final class Delta extends Fixed2ArgFunction {
return result == 0 ? ONE : ZERO;
}
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
if (args.length == 2) {
return evaluate(ec.getRowIndex(), ec.getColumnIndex(), args[0], args[1]);
}
return ErrorEval.VALUE_INVALID;
}
}

View File

@ -0,0 +1,13 @@
package org.apache.poi.ss.formula.functions;
/**
* Tests DELTA() as loaded from a test data spreadsheet.<p/>
*
* @author cedric dot walter @ gmail dot com
*/
public class TestDeltaFunctionsFromSpreadsheet extends BaseTestFunctionsFromSpreadsheet {
protected String getFilename() {
return "DeltaFunctionTestCaseData.xls";
}
}

Binary file not shown.