Search in sources :

Example 31 with NumberEval

use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.

the class TestTrunc method testNegative.

public void testNegative() {
    ValueEval[] args = { new NumberEval(-8.9), new NumberEval(0) };
    @SuppressWarnings("static-access") ValueEval result = F.TRUNC.evaluate(args, -1, (short) -1);
    assertEquals("TRUNC", (new NumberEval(-8)).getNumberValue(), ((NumberEval) result).getNumberValue());
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval) NumberEval(org.apache.poi.ss.formula.eval.NumberEval)

Example 32 with NumberEval

use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.

the class TestTrunc method testTruncWithDecimalNumber.

public void testTruncWithDecimalNumber() {
    ValueEval[] args = { new NumberEval(2.612777), new NumberEval(3) };
    @SuppressWarnings("static-access") ValueEval result = F.TRUNC.evaluate(args, -1, (short) -1);
    assertEquals("TRUNC", (new NumberEval(2.612d)).getNumberValue(), ((NumberEval) result).getNumberValue());
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval) NumberEval(org.apache.poi.ss.formula.eval.NumberEval)

Example 33 with NumberEval

use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.

the class TestXYNumericFunction 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.REF_INVALID);
    confirmError(areaEvalY, areaEvalX, ErrorEval.NULL_INTERSECTION);
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval) NumberEval(org.apache.poi.ss.formula.eval.NumberEval)

Example 34 with NumberEval

use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.

the class TestPercentile method testBlanks.

public void testBlanks() {
    ValueEval[] values = { new NumberEval(210.128), new NumberEval(65.2182), new NumberEval(32.231), BlankEval.instance, new NumberEval(45.32) };
    ValueEval percentile = new NumberEval(0.95);
    confirmPercentile(percentile, values, 188.39153);
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval) NumberEval(org.apache.poi.ss.formula.eval.NumberEval)

Example 35 with NumberEval

use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.

the class TestPercentile method testErrors.

//here we test where there are errors as part of inputs
public void testErrors() {
    ValueEval[] values = { new NumberEval(1), ErrorEval.NAME_INVALID, new NumberEval(3), ErrorEval.DIV_ZERO };
    ValueEval percentile = new NumberEval(0.95);
    confirmPercentile(percentile, values, ErrorEval.NAME_INVALID);
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval) NumberEval(org.apache.poi.ss.formula.eval.NumberEval)

Aggregations

NumberEval (org.apache.poi.ss.formula.eval.NumberEval)123 ValueEval (org.apache.poi.ss.formula.eval.ValueEval)101 Test (org.junit.Test)34 StringEval (org.apache.poi.ss.formula.eval.StringEval)29 AreaEval (org.apache.poi.ss.formula.eval.AreaEval)21 EvaluationException (org.apache.poi.ss.formula.eval.EvaluationException)19 Calendar (java.util.Calendar)17 Date (java.util.Date)13 NumericValueEval (org.apache.poi.ss.formula.eval.NumericValueEval)12 ErrorEval (org.apache.poi.ss.formula.eval.ErrorEval)8 I_MatchPredicate (org.apache.poi.ss.formula.functions.CountUtils.I_MatchPredicate)5 RefEval (org.apache.poi.ss.formula.eval.RefEval)4 AssertionFailedError (junit.framework.AssertionFailedError)3 ValueVector (org.apache.poi.ss.formula.functions.LookupUtils.ValueVector)3 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)2 BoolEval (org.apache.poi.ss.formula.eval.BoolEval)2 Workbook (org.apache.poi.ss.usermodel.Workbook)2 DateFormatSymbols (java.text.DateFormatSymbols)1 DecimalFormatSymbols (java.text.DecimalFormatSymbols)1 SimpleDateFormat (java.text.SimpleDateFormat)1