Search in sources :

Example 61 with ValueEval

use of org.apache.poi.ss.formula.eval.ValueEval in project poi by apache.

the class TestEvaluationCache method confirmEvaluate.

private static void confirmEvaluate(MySheet ms, String cellRefText, double expectedValue) {
    ValueEval v = ms.evaluateCell(cellRefText);
    assertEquals(NumberEval.class, v.getClass());
    assertEquals(expectedValue, ((NumberEval) v).getNumberValue(), 0.0);
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval)

Example 62 with ValueEval

use of org.apache.poi.ss.formula.eval.ValueEval in project poi by apache.

the class TestWorkbookEvaluator method testMemFunc.

/**
     * Make sure that the evaluator can directly handle tAttrSum (instead of relying on re-parsing
     * the whole formula which converts tAttrSum to tFuncVar("SUM") )
     */
@Test
public void testMemFunc() {
    Ptg[] ptgs = { new IntPtg(42), AttrPtg.SUM };
    ValueEval result = evaluateFormula(ptgs);
    assertEquals(42, ((NumberEval) result).getNumberValue(), 0.0);
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval) Test(org.junit.Test)

Example 63 with ValueEval

use of org.apache.poi.ss.formula.eval.ValueEval in project poi by apache.

the class TestPercentile method testBlanks.

public void testBlanks() {
    ValueEval[] values = { new NumberEval(210.128), new NumberEval(65.2182), new NumberEval(32.231), BlankEval.instance, new NumberEval(45.32) };
    ValueEval percentile = new NumberEval(0.95);
    confirmPercentile(percentile, values, 188.39153);
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval) NumberEval(org.apache.poi.ss.formula.eval.NumberEval)

Example 64 with ValueEval

use of org.apache.poi.ss.formula.eval.ValueEval in project poi by apache.

the class TestPercentile method testErrors.

//here we test where there are errors as part of inputs
public void testErrors() {
    ValueEval[] values = { new NumberEval(1), ErrorEval.NAME_INVALID, new NumberEval(3), ErrorEval.DIV_ZERO };
    ValueEval percentile = new NumberEval(0.95);
    confirmPercentile(percentile, values, ErrorEval.NAME_INVALID);
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval) NumberEval(org.apache.poi.ss.formula.eval.NumberEval)

Example 65 with ValueEval

use of org.apache.poi.ss.formula.eval.ValueEval in project poi by apache.

the class TestPercentile method testUnusualArgs3.

//percentile has to be between 0 and 1 - here we test more than 1
public void testUnusualArgs3() {
    ValueEval[] values = { new NumberEval(1), new NumberEval(2) };
    ValueEval percentile = new NumberEval(1.1);
    confirmPercentile(percentile, values, ErrorEval.NUM_ERROR);
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval) NumberEval(org.apache.poi.ss.formula.eval.NumberEval)

Aggregations

ValueEval (org.apache.poi.ss.formula.eval.ValueEval)223 NumberEval (org.apache.poi.ss.formula.eval.NumberEval)101 StringEval (org.apache.poi.ss.formula.eval.StringEval)48 Test (org.junit.Test)39 EvaluationException (org.apache.poi.ss.formula.eval.EvaluationException)36 AreaEval (org.apache.poi.ss.formula.eval.AreaEval)29 NumericValueEval (org.apache.poi.ss.formula.eval.NumericValueEval)28 OperationEvaluationContext (org.apache.poi.ss.formula.OperationEvaluationContext)27 Calendar (java.util.Calendar)16 ErrorEval (org.apache.poi.ss.formula.eval.ErrorEval)13 Date (java.util.Date)11 RefEval (org.apache.poi.ss.formula.eval.RefEval)9 TwoDEval (org.apache.poi.ss.formula.TwoDEval)7 BlankEval (org.apache.poi.ss.formula.eval.BlankEval)4 NotImplementedException (org.apache.poi.ss.formula.eval.NotImplementedException)4 StringValueEval (org.apache.poi.ss.formula.eval.StringValueEval)4 ValueVector (org.apache.poi.ss.formula.functions.LookupUtils.ValueVector)4 ArrayList (java.util.ArrayList)3 AssertionFailedError (junit.framework.AssertionFailedError)3 BoolEval (org.apache.poi.ss.formula.eval.BoolEval)3