Search in sources :

Example 41 with NumberEval

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

the class TestWorkdayFunction method testReturnWorkdaysWithDaysTruncated.

@Test
public void testReturnWorkdaysWithDaysTruncated() {
    Calendar expCal = LocaleUtil.getLocaleCalendar(2009, 3, 30);
    Date expDate = expCal.getTime();
    ValueEval[] ve = { new StringEval(STARTING_DATE), new NumberEval(151.99999) };
    double numberValue = ((NumberEval) WorkdayFunction.instance.evaluate(ve, EC)).getNumberValue();
    Date actDate = DateUtil.getJavaDate(numberValue);
    assertEquals(expDate, actDate);
}
Also used : Calendar(java.util.Calendar) StringEval(org.apache.poi.ss.formula.eval.StringEval) ValueEval(org.apache.poi.ss.formula.eval.ValueEval) Date(java.util.Date) NumberEval(org.apache.poi.ss.formula.eval.NumberEval) Test(org.junit.Test)

Example 42 with NumberEval

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

the class TestWorkdayFunction method testReturnRetroativeWorkday.

@Test
public void testReturnRetroativeWorkday() {
    Calendar expCal = LocaleUtil.getLocaleCalendar(2008, 8, 23);
    Date expDate = expCal.getTime();
    ValueEval[] ve = { new StringEval(STARTING_DATE), new NumberEval(-5), new StringEval(RETROATIVE_HOLIDAY) };
    double numberValue = ((NumberEval) WorkdayFunction.instance.evaluate(ve, EC)).getNumberValue();
    Date actDate = DateUtil.getJavaDate(numberValue);
    assertEquals(expDate, actDate);
}
Also used : Calendar(java.util.Calendar) StringEval(org.apache.poi.ss.formula.eval.StringEval) ValueEval(org.apache.poi.ss.formula.eval.ValueEval) Date(java.util.Date) NumberEval(org.apache.poi.ss.formula.eval.NumberEval) Test(org.junit.Test)

Example 43 with NumberEval

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

the class TestWorkdayFunction method testReturnWorkdays.

@Test
public void testReturnWorkdays() {
    Calendar expCal = LocaleUtil.getLocaleCalendar(2009, 3, 30);
    Date expDate = expCal.getTime();
    ValueEval[] ve = { new StringEval(STARTING_DATE), new NumberEval(151) };
    Date actDate = DateUtil.getJavaDate(((NumberEval) WorkdayFunction.instance.evaluate(ve, EC)).getNumberValue());
    assertEquals(expDate, actDate);
}
Also used : Calendar(java.util.Calendar) StringEval(org.apache.poi.ss.formula.eval.StringEval) ValueEval(org.apache.poi.ss.formula.eval.ValueEval) Date(java.util.Date) NumberEval(org.apache.poi.ss.formula.eval.NumberEval) Test(org.junit.Test)

Example 44 with NumberEval

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

the class TestWorkdayFunction method testReturnWorkdaysSpanningAWeekendAddingDays.

@Test
public void testReturnWorkdaysSpanningAWeekendAddingDays() {
    Calendar expCal = LocaleUtil.getLocaleCalendar(2013, 8, 30);
    Date expDate = expCal.getTime();
    ValueEval[] ve = { new StringEval("2013/09/27"), new NumberEval(1) };
    double numberValue = ((NumberEval) WorkdayFunction.instance.evaluate(ve, EC)).getNumberValue();
    assertEquals(41547.0, numberValue, 0);
    Date actDate = DateUtil.getJavaDate(numberValue);
    assertEquals(expDate, actDate);
}
Also used : Calendar(java.util.Calendar) StringEval(org.apache.poi.ss.formula.eval.StringEval) ValueEval(org.apache.poi.ss.formula.eval.ValueEval) Date(java.util.Date) NumberEval(org.apache.poi.ss.formula.eval.NumberEval) Test(org.junit.Test)

Example 45 with NumberEval

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

the class TestDec2Bin method testWithZeroPlaces.

public void testWithZeroPlaces() {
    OperationEvaluationContext ctx = createContext();
    ValueEval[] args = new ValueEval[] { ctx.getRefEval(0, 0), new NumberEval(0.0) };
    ValueEval result = new Dec2Bin().evaluate(args, -1, -1);
    assertEquals(ErrorEval.class, result.getClass());
    assertEquals(ErrorEval.NUM_ERROR, result);
}
Also used : OperationEvaluationContext(org.apache.poi.ss.formula.OperationEvaluationContext) 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