use of org.apache.poi.ss.formula.eval.StringEval in project poi by apache.
the class TestWorkdayFunction method testReturnWorkdays.
@Test
public void testReturnWorkdays() {
Calendar expCal = LocaleUtil.getLocaleCalendar(2009, 3, 30);
Date expDate = expCal.getTime();
ValueEval[] ve = { new StringEval(STARTING_DATE), new NumberEval(151) };
Date actDate = DateUtil.getJavaDate(((NumberEval) WorkdayFunction.instance.evaluate(ve, EC)).getNumberValue());
assertEquals(expDate, actDate);
}
use of org.apache.poi.ss.formula.eval.StringEval in project poi by apache.
the class TestWorkdayFunction method testReturnWorkdaysSpanningAWeekendAddingDays.
@Test
public void testReturnWorkdaysSpanningAWeekendAddingDays() {
Calendar expCal = LocaleUtil.getLocaleCalendar(2013, 8, 30);
Date expDate = expCal.getTime();
ValueEval[] ve = { new StringEval("2013/09/27"), new NumberEval(1) };
double numberValue = ((NumberEval) WorkdayFunction.instance.evaluate(ve, EC)).getNumberValue();
assertEquals(41547.0, numberValue, 0);
Date actDate = DateUtil.getJavaDate(numberValue);
assertEquals(expDate, actDate);
}
use of org.apache.poi.ss.formula.eval.StringEval in project poi by apache.
the class TestMid method testExtremes.
/**
* Extreme values for startPos and numChars
*/
public void testExtremes() {
confirmMid(new StringEval("galactic"), new NumberEval(4), new NumberEval(400), "actic");
confirmMid(new StringEval("galactic"), new NumberEval(30), new NumberEval(4), "");
confirmMid(new StringEval("galactic"), new NumberEval(3), new NumberEval(0), "");
}
use of org.apache.poi.ss.formula.eval.StringEval in project poi by apache.
the class TestFixed method testOptionalParams.
@Test
public void testOptionalParams() {
Fixed fixed = new Fixed();
ValueEval evaluate = fixed.evaluate(0, 0, new NumberEval(1234.56789));
assertTrue(evaluate instanceof StringEval);
assertEquals("1,234.57", ((StringEval) evaluate).getStringValue());
evaluate = fixed.evaluate(0, 0, new NumberEval(1234.56789), new NumberEval(1));
assertTrue(evaluate instanceof StringEval);
assertEquals("1,234.6", ((StringEval) evaluate).getStringValue());
evaluate = fixed.evaluate(0, 0, new NumberEval(1234.56789), new NumberEval(1), BoolEval.TRUE);
assertTrue(evaluate instanceof StringEval);
assertEquals("1234.6", ((StringEval) evaluate).getStringValue());
evaluate = fixed.evaluate(new ValueEval[] {}, 1, 1);
assertTrue(evaluate instanceof ErrorEval);
evaluate = fixed.evaluate(new ValueEval[] { new NumberEval(1), new NumberEval(1), new NumberEval(1), new NumberEval(1) }, 1, 1);
assertTrue(evaluate instanceof ErrorEval);
}
use of org.apache.poi.ss.formula.eval.StringEval 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);
}
Aggregations