use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.
the class TestTrunc method testTruncWithDecimalNumberOneArg.
public void testTruncWithDecimalNumberOneArg() {
ValueEval[] args = { new NumberEval(2.612777) };
ValueEval result = NumericFunction.TRUNC.evaluate(args, -1, (short) -1);
assertEquals("TRUNC", (new NumberEval(2d)).getNumberValue(), ((NumberEval) result).getNumberValue());
}
use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.
the class TestSlope method testErrors.
public void testErrors() {
ValueEval[] xValues = { ErrorEval.REF_INVALID, new NumberEval(2) };
ValueEval areaEvalX = createAreaEval(xValues);
ValueEval[] yValues = { new NumberEval(2), ErrorEval.NULL_INTERSECTION };
ValueEval areaEvalY = createAreaEval(yValues);
ValueEval[] zValues = { // wrong size
new NumberEval(2) };
ValueEval areaEvalZ = createAreaEval(zValues);
// if either arg is an error, that error propagates
confirmError(ErrorEval.REF_INVALID, ErrorEval.NAME_INVALID, ErrorEval.REF_INVALID);
confirmError(areaEvalX, ErrorEval.NAME_INVALID, ErrorEval.NAME_INVALID);
confirmError(ErrorEval.NAME_INVALID, areaEvalX, ErrorEval.NAME_INVALID);
// array sizes must match
confirmError(areaEvalX, areaEvalZ, ErrorEval.NA);
confirmError(areaEvalZ, areaEvalY, ErrorEval.NA);
// any error in an array item propagates up
confirmError(areaEvalX, areaEvalX, ErrorEval.REF_INVALID);
// search for errors array by array, not pair by pair
confirmError(areaEvalX, areaEvalY, ErrorEval.NULL_INTERSECTION);
confirmError(areaEvalY, areaEvalX, ErrorEval.REF_INVALID);
}
use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.
the class TestSlope method testLargeArrays.
/**
* number of items in array is not limited to 30
*/
public void testLargeArrays() {
// [1,2,0,1,2,0,...,0,1]
ValueEval[] yValues = createMockNumberArray(100, 3);
// Changes first element to 2
yValues[0] = new NumberEval(2.0);
// [1,2,3,4,...,99,100]
ValueEval[] xValues = createMockNumberArray(100, 101);
confirm(SLOPE, createAreaEval(xValues), createAreaEval(yValues), -1.231527093596059);
// Excel 2010 gives -1.23152709359606
}
use of org.apache.poi.ss.formula.eval.NumberEval 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.NumberEval in project poi by apache.
the class TestPoisson method testXAsDecimalNumber.
public void testXAsDecimalNumber() {
double x = 1.1;
double mean = 0.2;
// known result
double result = 0.9824769036935787;
NumberEval myResult = (NumberEval) invokePoisson(x, mean, true);
assertEquals(myResult.getNumberValue(), result, DELTA);
}
Aggregations