use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.
the class TestEDate method checkValue.
private void checkValue(int startDate, int monthInc, double expectedResult) {
EDate eDate = new EDate();
NumberEval result = (NumberEval) eDate.evaluate(new ValueEval[] { new NumberEval(startDate), new NumberEval(monthInc) }, null);
assertEquals(expectedResult, result.getNumberValue(), 0);
}
use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.
the class TestEDate method testEDateIncrease.
@Test
public void testEDateIncrease() {
EDate eDate = new EDate();
Date startDate = new Date();
int offset = 2;
NumberEval result = (NumberEval) eDate.evaluate(new ValueEval[] { new NumberEval(DateUtil.getExcelDate(startDate)), new NumberEval(offset) }, null);
Date resultDate = DateUtil.getJavaDate(result.getNumberValue());
Calendar instance = LocaleUtil.getLocaleCalendar();
instance.setTime(startDate);
instance.add(Calendar.MONTH, offset);
assertEquals(resultDate, instance.getTime());
}
use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.
the class TestEOMonth method testEOMonthInvalidArguments.
@Test
public void testEOMonthInvalidArguments() {
ValueEval result = eOMonth.evaluate(new ValueEval[] { new NumberEval(DATE_1902_09_26) }, ec);
assertTrue(result instanceof ErrorEval);
assertEquals(FormulaError.VALUE.getCode(), ((ErrorEval) result).getErrorCode(), 0);
result = eOMonth.evaluate(new ValueEval[] { new StringEval("a"), new StringEval("b") }, ec);
assertTrue(result instanceof ErrorEval);
assertEquals(FormulaError.VALUE.getCode(), ((ErrorEval) result).getErrorCode(), 0);
}
use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.
the class TestEOMonth method testEOMonthBlankValueEval.
@Test
public void testEOMonthBlankValueEval() {
NumberEval evaluate = (NumberEval) eOMonth.evaluate(new ValueEval[] { BlankEval.instance, new NumberEval(0) }, ec);
assertEquals("Blank is handled as 0", DATE_1900_01_31, evaluate.getNumberValue(), 0);
}
use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.
the class TestEOMonth method testEOMonthBlankRefValueEval.
@Test
public void testEOMonthBlankRefValueEval() {
ValueEval[] ve1 = { new RefEvalImplementation(BlankEval.instance), new NumberEval(1) };
NumberEval result = (NumberEval) eOMonth.evaluate(ve1, ec);
assertEquals("Blank is handled as 0", DATE_1900_02_28, result.getNumberValue(), 0);
ValueEval[] ve2 = { new NumberEval(1), new RefEvalImplementation(BlankEval.instance) };
result = (NumberEval) eOMonth.evaluate(ve2, ec);
assertEquals("Blank is handled as 0", DATE_1900_01_31, result.getNumberValue(), 0);
}
Aggregations