use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.
the class TestIndex method confirmAreaEval.
/**
* @param areaRefString in Excel notation e.g. 'D2:E97'
* @param dValues array of evaluated values for the area reference
* @param rowNum 1-based
* @param colNum 1-based, pass -1 to signify argument not present
*/
private static void confirmAreaEval(String areaRefString, double[] dValues, int rowNum, int colNum, double expectedResult) {
ValueEval[] values = new ValueEval[dValues.length];
for (int i = 0; i < values.length; i++) {
values[i] = new NumberEval(dValues[i]);
}
AreaEval arg0 = EvalFactory.createAreaEval(areaRefString, values);
ValueEval[] args;
if (colNum > 0) {
args = new ValueEval[] { arg0, new NumberEval(rowNum), new NumberEval(colNum) };
} else {
args = new ValueEval[] { arg0, new NumberEval(rowNum) };
}
double actual = invokeAndDereference(args);
assertEquals(expectedResult, actual, 0D);
}
use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.
the class TestEDate method testEDateInvalidValues.
@Test
public void testEDateInvalidValues() {
EDate eDate = new EDate();
ErrorEval result = (ErrorEval) eDate.evaluate(new ValueEval[] { new NumberEval(1000) }, null);
assertEquals(FormulaError.VALUE.getCode(), result.getErrorCode(), 0);
}
use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.
the class TestEDate method testEDateInvalidValueEval.
@Test
public void testEDateInvalidValueEval() {
ValueEval evaluate = new EDate().evaluate(new ValueEval[] { new ValueEval() {
}, new NumberEval(0) }, null);
assertTrue(evaluate instanceof ErrorEval);
assertEquals(ErrorEval.VALUE_INVALID, evaluate);
}
use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.
the class TestLen method testUnusualArgs.
/**
* Valid cases where text arg is not exactly a string
*/
public void testUnusualArgs() {
// text (first) arg type is number, other args are strings with fractional digits
confirmLen(new NumberEval(123456), 6);
confirmLen(BoolEval.FALSE, 5);
confirmLen(BoolEval.TRUE, 4);
confirmLen(BlankEval.instance, 0);
}
use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.
the class TestIndex method invokeAndDereference.
private static double invokeAndDereference(ValueEval[] args) {
ValueEval ve = FUNC_INST.evaluate(args, -1, -1);
ve = WorkbookEvaluator.dereferenceResult(ve, -1, -1);
assertEquals(NumberEval.class, ve.getClass());
return ((NumberEval) ve).getNumberValue();
}
Aggregations