Search in sources :

Example 91 with ValueEval

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

the class TestEDate method testEDateBlankRefValueEval.

@Test
public void testEDateBlankRefValueEval() {
    EDate eDate = new EDate();
    NumberEval result = (NumberEval) eDate.evaluate(new ValueEval[] { new RefEvalImplementation(BlankEval.instance), new NumberEval(0) }, null);
    assertEquals("0 startDate triggers BAD_DATE currently, thus -1.0!", -1.0d, result.getNumberValue(), 0);
    result = (NumberEval) eDate.evaluate(new ValueEval[] { new NumberEval(1), new RefEvalImplementation(BlankEval.instance) }, null);
    assertEquals("Blank is handled as 0 otherwise", 1.0d, result.getNumberValue(), 0);
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval) NumberEval(org.apache.poi.ss.formula.eval.NumberEval) Test(org.junit.Test)

Example 92 with ValueEval

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

the class TestEDate method testEDateBlankValueEval.

@Test
public void testEDateBlankValueEval() {
    NumberEval evaluate = (NumberEval) new EDate().evaluate(new ValueEval[] { BlankEval.instance, new NumberEval(0) }, null);
    assertEquals(-1.0d, evaluate.getNumberValue(), 0);
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval) NumberEval(org.apache.poi.ss.formula.eval.NumberEval) Test(org.junit.Test)

Example 93 with ValueEval

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

the class TestEDate method testRefEvalStartDate.

@Test
public void testRefEvalStartDate() {
    EDate eDate = new EDate();
    NumberEval result = (NumberEval) eDate.evaluate(new ValueEval[] { new RefEvalImplementation(new NumberEval(1000)), new NumberEval(0) }, null);
    assertEquals(1000d, result.getNumberValue(), 0);
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval) NumberEval(org.apache.poi.ss.formula.eval.NumberEval) Test(org.junit.Test)

Example 94 with ValueEval

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

the class TestEOMonth method checkValue.

private void checkValue(double startDate, int monthInc, double expectedResult) {
    ValueEval[] ve = { new NumberEval(startDate), new NumberEval(monthInc) };
    NumberEval result = (NumberEval) eOMonth.evaluate(ve, ec);
    assertEquals(expectedResult, result.getNumberValue(), 0);
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval) NumberEval(org.apache.poi.ss.formula.eval.NumberEval)

Example 95 with ValueEval

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

the class TestEDate method testBug56688.

@Test
public void testBug56688() {
    EDate eDate = new EDate();
    NumberEval result = (NumberEval) eDate.evaluate(new ValueEval[] { new NumberEval(1000), new RefEvalImplementation(new NumberEval(0)) }, null);
    assertEquals(1000d, result.getNumberValue(), 0);
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval) NumberEval(org.apache.poi.ss.formula.eval.NumberEval) Test(org.junit.Test)

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