Search in sources :

Example 76 with NumberEval

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

the class TestCellCacheEntry method testBasic.

public void testBasic() {
    CellCacheEntry pcce = new PlainValueCellCacheEntry(new NumberEval(42.0));
    ValueEval ve = pcce.getValue();
    assertEquals(42, ((NumberEval) ve).getNumberValue(), 0.0);
    FormulaCellCacheEntry fcce = new FormulaCellCacheEntry();
    fcce.updateFormulaResult(new NumberEval(10.0), CellCacheEntry.EMPTY_ARRAY, null);
    ve = fcce.getValue();
    assertEquals(10, ((NumberEval) ve).getNumberValue(), 0.0);
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval) NumberEval(org.apache.poi.ss.formula.eval.NumberEval)

Example 77 with NumberEval

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

the class TestPercentile method testUnusualArgs.

public void testUnusualArgs() {
    ValueEval[] values = { new NumberEval(1), new NumberEval(2), BoolEval.TRUE, BoolEval.FALSE };
    ValueEval percentile = new NumberEval(0.95);
    confirmPercentile(percentile, values, 1.95);
}
Also used : ValueEval(org.apache.poi.ss.formula.eval.ValueEval) NumberEval(org.apache.poi.ss.formula.eval.NumberEval)

Example 78 with NumberEval

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

the class TestPercentile method testBasic.

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

Example 79 with NumberEval

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

the class TestPercentile method testErrors2.

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

Example 80 with NumberEval

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

the class TestPercentile method testUnusualArgs2.

//percentile has to be between 0 and 1 - here we test less than zero
public void testUnusualArgs2() {
    ValueEval[] values = { new NumberEval(1), new NumberEval(2) };
    ValueEval percentile = new NumberEval(-0.1);
    confirmPercentile(percentile, values, ErrorEval.NUM_ERROR);
}
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