Search in sources :

Example 51 with ValueEval

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

the class TestOct2Dec method confirmValueError.

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

Example 52 with ValueEval

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

the class TestOct2Dec method confirmValue.

private static void confirmValue(String msg, String number1, String expected) {
    ValueEval result = invokeValue(number1);
    assertEquals(NumberEval.class, result.getClass());
    assertEquals(msg, expected, ((NumberEval) result).getStringValue());
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval)

Example 53 with ValueEval

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

the class TestMatch method testInvalidMatchType.

public void testInvalidMatchType() {
    ValueEval[] values = { new NumberEval(4), new NumberEval(5), new NumberEval(10), new NumberEval(10), new NumberEval(25) };
    AreaEval ae = EvalFactory.createAreaEval("A1:A5", values);
    confirmInt(2, invokeMatch(new NumberEval(5), ae, MATCH_LARGEST_LTE));
    assertEquals("Should return #REF! for invalid match type", ErrorEval.REF_INVALID, invokeMatch(new StringEval("Ben"), ae, MATCH_INVALID));
}
Also used : NumericValueEval(org.apache.poi.ss.formula.eval.NumericValueEval) ValueEval(org.apache.poi.ss.formula.eval.ValueEval) StringEval(org.apache.poi.ss.formula.eval.StringEval) AreaEval(org.apache.poi.ss.formula.eval.AreaEval) NumberEval(org.apache.poi.ss.formula.eval.NumberEval)

Example 54 with ValueEval

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

the class TestMatch method testTildeString.

public void testTildeString() {
    ValueEval[] values = { new StringEval("what?"), new StringEval("all*") };
    AreaEval ae = EvalFactory.createAreaEval("A1:A2", values);
    confirmInt(1, invokeMatch(new StringEval("what~?"), ae, MATCH_EXACT));
    confirmInt(2, invokeMatch(new StringEval("all~*"), ae, MATCH_EXACT));
}
Also used : StringEval(org.apache.poi.ss.formula.eval.StringEval) NumericValueEval(org.apache.poi.ss.formula.eval.NumericValueEval) ValueEval(org.apache.poi.ss.formula.eval.ValueEval) AreaEval(org.apache.poi.ss.formula.eval.AreaEval)

Example 55 with ValueEval

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

the class TestTrunc method testNegative.

public void testNegative() {
    ValueEval[] args = { new NumberEval(-8.9), new NumberEval(0) };
    @SuppressWarnings("static-access") ValueEval result = F.TRUNC.evaluate(args, -1, (short) -1);
    assertEquals("TRUNC", (new NumberEval(-8)).getNumberValue(), ((NumberEval) result).getNumberValue());
}
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