use of org.apache.poi.ss.formula.eval.ValueEval in project poi by apache.
the class TestDec2Bin method testWithTooManyParamsIntInt.
public void testWithTooManyParamsIntInt() {
OperationEvaluationContext ctx = createContext();
ValueEval[] args = new ValueEval[] { ctx.getRefEval(0, 0), ctx.getRefEval(0, 1), ctx.getRefEval(0, 1) };
ValueEval result = new Dec2Bin().evaluate(args, -1, -1);
assertEquals(ErrorEval.class, result.getClass());
assertEquals(ErrorEval.VALUE_INVALID, result);
}
use of org.apache.poi.ss.formula.eval.ValueEval in project poi by apache.
the class TestHex2Dec method testEvalOperationEvaluationContext.
public void testEvalOperationEvaluationContext() {
OperationEvaluationContext ctx = createContext();
ValueEval[] args = new ValueEval[] { ctx.getRefEval(0, 0) };
ValueEval result = new Hex2Dec().evaluate(args, ctx);
assertEquals(NumberEval.class, result.getClass());
assertEquals("0", ((NumberEval) result).getStringValue());
}
use of org.apache.poi.ss.formula.eval.ValueEval in project poi by apache.
the class TestHex2Dec method testEvalOperationEvaluationContextFails.
public void testEvalOperationEvaluationContextFails() {
OperationEvaluationContext ctx = createContext();
ValueEval[] args = new ValueEval[] { ctx.getRefEval(0, 0), ctx.getRefEval(0, 0) };
ValueEval result = new Hex2Dec().evaluate(args, ctx);
assertEquals(ErrorEval.class, result.getClass());
assertEquals(ErrorEval.VALUE_INVALID, result);
}
use of org.apache.poi.ss.formula.eval.ValueEval in project poi by apache.
the class TestIndex method testReferenceResult.
/**
* When the argument to INDEX is a reference, the result should be a reference
* A formula like "OFFSET(INDEX(A1:B2,2,1),1,1,1,1)" should return the value of cell B3.
* This works because the INDEX() function returns a reference to A2 (not the value of A2)
*/
public void testReferenceResult() {
ValueEval[] values = new ValueEval[4];
Arrays.fill(values, NumberEval.ZERO);
AreaEval arg0 = EvalFactory.createAreaEval("A1:B2", values);
ValueEval[] args = new ValueEval[] { arg0, new NumberEval(2), new NumberEval(1) };
ValueEval ve = FUNC_INST.evaluate(args, -1, -1);
confirmAreaEval("A2:A2", ve);
}
use of org.apache.poi.ss.formula.eval.ValueEval in project poi by apache.
the class TestIndex method testMissingArg.
/**
* Tests expressions like "INDEX(A1:C1,,2)".<br/>
* This problem was found while fixing bug 47048 and is observable up to svn r773441.
*/
public void testMissingArg() {
ValueEval[] values = { new NumberEval(25.0), new NumberEval(26.0), new NumberEval(28.0) };
AreaEval arg0 = EvalFactory.createAreaEval("A10:C10", values);
ValueEval[] args = new ValueEval[] { arg0, MissingArgEval.instance, new NumberEval(2) };
ValueEval actualResult;
try {
actualResult = FUNC_INST.evaluate(args, -1, -1);
} catch (RuntimeException e) {
if (e.getMessage().equals("Unexpected arg eval type (org.apache.poi.hssf.record.formula.eval.MissingArgEval")) {
throw new AssertionFailedError("Identified bug 47048b - INDEX() should support missing-arg");
}
throw e;
}
// result should be an area eval "B10:B10"
AreaEval ae = confirmAreaEval("B10:B10", actualResult);
actualResult = ae.getValue(0, 0);
assertEquals(NumberEval.class, actualResult.getClass());
assertEquals(26.0, ((NumberEval) actualResult).getNumberValue(), 0.0);
}
Aggregations