use of org.apache.poi.ss.formula.eval.ErrorEval in project poi by apache.
the class TestPmt method test3args.
@Test
public void test3args() {
ValueEval[] args = { new NumberEval(0.005), new NumberEval(24), new NumberEval(1000) };
ValueEval ev = invoke(args);
if (ev instanceof ErrorEval) {
ErrorEval err = (ErrorEval) ev;
if (err.getErrorCode() == FormulaError.VALUE.getCode()) {
fail("Identified bug 44691");
}
}
confirm(-44.3206, invokeNormal(args));
}
use of org.apache.poi.ss.formula.eval.ErrorEval in project poi by apache.
the class TestPoisson method testNegativeMean.
public void testNegativeMean() {
double x = 0;
double mean = -0.2;
ErrorEval myResult = (ErrorEval) invokePoisson(x, mean, false);
assertEquals(ErrorEval.NUM_ERROR.getErrorCode(), myResult.getErrorCode());
}
use of org.apache.poi.ss.formula.eval.ErrorEval in project poi by apache.
the class NumericFunctionInvoker method invokeInternal.
/**
* Formats nicer error messages for the junit output
*/
private static double invokeInternal(Function target, ValueEval[] args, int srcCellRow, int srcCellCol) throws NumericEvalEx {
ValueEval evalResult;
try {
evalResult = target.evaluate(args, srcCellRow, (short) srcCellCol);
} catch (NotImplementedException e) {
throw new NumericEvalEx("Not implemented:" + e.getMessage());
}
if (evalResult == null) {
throw new NumericEvalEx("Result object was null");
}
if (evalResult instanceof ErrorEval) {
ErrorEval ee = (ErrorEval) evalResult;
throw new NumericEvalEx(formatErrorMessage(ee));
}
if (!(evalResult instanceof NumericValueEval)) {
throw new NumericEvalEx("Result object type (" + evalResult.getClass().getName() + ") is invalid. Expected implementor of (" + NumericValueEval.class.getName() + ")");
}
NumericValueEval result = (NumericValueEval) evalResult;
return result.getNumberValue();
}
use of org.apache.poi.ss.formula.eval.ErrorEval 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.ErrorEval 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);
}
Aggregations