Search in sources :

Example 41 with ValueEval

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

the class TestTrim method confirmTrim.

private void confirmTrim(ValueEval text, String expected) {
    ValueEval result = invokeTrim(text);
    assertEquals(StringEval.class, result.getClass());
    assertEquals(expected, ((StringEval) result).getStringValue());
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval)

Example 42 with ValueEval

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

the class TestTrunc method testTruncWithDecimalNumberOneArg.

public void testTruncWithDecimalNumberOneArg() {
    ValueEval[] args = { new NumberEval(2.612777) };
    ValueEval result = NumericFunction.TRUNC.evaluate(args, -1, (short) -1);
    assertEquals("TRUNC", (new NumberEval(2d)).getNumberValue(), ((NumberEval) result).getNumberValue());
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval) NumberEval(org.apache.poi.ss.formula.eval.NumberEval)

Example 43 with ValueEval

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

the class TestQuotient method confirmValueError.

private static void confirmValueError(String msg, String numerator, String denominator, ErrorEval numError) {
    ValueEval result = invokeValue(numerator, denominator);
    assertEquals(ErrorEval.class, result.getClass());
    assertEquals(msg, numError, result);
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval)

Example 44 with ValueEval

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

the class TestSlope method testErrors.

public void testErrors() {
    ValueEval[] xValues = { ErrorEval.REF_INVALID, new NumberEval(2) };
    ValueEval areaEvalX = createAreaEval(xValues);
    ValueEval[] yValues = { new NumberEval(2), ErrorEval.NULL_INTERSECTION };
    ValueEval areaEvalY = createAreaEval(yValues);
    ValueEval[] zValues = { // wrong size
    new NumberEval(2) };
    ValueEval areaEvalZ = createAreaEval(zValues);
    // if either arg is an error, that error propagates
    confirmError(ErrorEval.REF_INVALID, ErrorEval.NAME_INVALID, ErrorEval.REF_INVALID);
    confirmError(areaEvalX, ErrorEval.NAME_INVALID, ErrorEval.NAME_INVALID);
    confirmError(ErrorEval.NAME_INVALID, areaEvalX, ErrorEval.NAME_INVALID);
    // array sizes must match
    confirmError(areaEvalX, areaEvalZ, ErrorEval.NA);
    confirmError(areaEvalZ, areaEvalY, ErrorEval.NA);
    // any error in an array item propagates up
    confirmError(areaEvalX, areaEvalX, ErrorEval.REF_INVALID);
    // search for errors array by array, not pair by pair
    confirmError(areaEvalX, areaEvalY, ErrorEval.NULL_INTERSECTION);
    confirmError(areaEvalY, areaEvalX, ErrorEval.REF_INVALID);
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval) NumberEval(org.apache.poi.ss.formula.eval.NumberEval)

Example 45 with ValueEval

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

the class TestSlope method confirm.

private void confirm(Function function, ValueEval xArray, ValueEval yArray, double expected) {
    ValueEval result = invoke(function, xArray, yArray);
    assertEquals(NumberEval.class, result.getClass());
    assertEquals(expected, ((NumberEval) result).getNumberValue(), 0);
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval)

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