use of org.apache.poi.ss.formula.eval.StringEval in project poi by apache.
the class TestCountFuncs method testCaseInsensitiveStringComparison.
/**
* String criteria in COUNTIF are case insensitive;
* for example, the string "apples" and the string "APPLES" will match the same cells.
*/
public void testCaseInsensitiveStringComparison() {
AreaEval range;
ValueEval[] values;
values = new ValueEval[] { new StringEval("no"), new StringEval("NO"), new StringEval("No"), new StringEval("Yes") };
range = EvalFactory.createAreaEval("A1:A4", values);
confirmCountIf(3, range, new StringEval("no"));
confirmCountIf(3, range, new StringEval("NO"));
confirmCountIf(3, range, new StringEval("No"));
}
use of org.apache.poi.ss.formula.eval.StringEval in project poi by apache.
the class TestCountFuncs method testCountBlank.
public void testCountBlank() {
AreaEval range;
ValueEval[] values;
values = new ValueEval[] { new NumberEval(0), // note - does match blank
new StringEval(""), BoolEval.TRUE, BoolEval.FALSE, ErrorEval.DIV_ZERO, BlankEval.instance };
range = EvalFactory.createAreaEval("A1:B3", values);
confirmCountBlank(2, range);
values = new ValueEval[] { new NumberEval(0), // does match blank
new StringEval(""), BlankEval.instance, BoolEval.FALSE, BoolEval.TRUE, BlankEval.instance };
range = EvalFactory.createAreaEval("A1:B3", values);
confirmCountBlank(3, range);
}
use of org.apache.poi.ss.formula.eval.StringEval in project poi by apache.
the class TestCountFuncs method testWildCards.
public void testWildCards() {
I_MatchPredicate mp;
mp = createCriteriaPredicate(new StringEval("a*b"));
confirmPredicate(false, mp, "abc");
confirmPredicate(true, mp, "ab");
confirmPredicate(true, mp, "axxb");
confirmPredicate(false, mp, "xab");
mp = createCriteriaPredicate(new StringEval("a?b"));
confirmPredicate(false, mp, "abc");
confirmPredicate(false, mp, "ab");
confirmPredicate(false, mp, "axxb");
confirmPredicate(false, mp, "xab");
confirmPredicate(true, mp, "axb");
mp = createCriteriaPredicate(new StringEval("a~?"));
confirmPredicate(false, mp, "a~a");
confirmPredicate(false, mp, "a~?");
confirmPredicate(true, mp, "a?");
mp = createCriteriaPredicate(new StringEval("~*a"));
confirmPredicate(false, mp, "~aa");
confirmPredicate(false, mp, "~*a");
confirmPredicate(true, mp, "*a");
mp = createCriteriaPredicate(new StringEval("12?12"));
confirmPredicate(false, mp, 12812);
confirmPredicate(true, mp, "12812");
confirmPredicate(false, mp, "128812");
}
use of org.apache.poi.ss.formula.eval.StringEval in project poi by apache.
the class TestWorkdayFunction method testReturnWorkdaysSpanningAWeekendSubtractingDays.
@Test
public void testReturnWorkdaysSpanningAWeekendSubtractingDays() {
Calendar expCal = LocaleUtil.getLocaleCalendar(2013, 8, 27);
Date expDate = expCal.getTime();
ValueEval[] ve = { new StringEval("2013/09/30"), new NumberEval(-1) };
double numberValue = ((NumberEval) WorkdayFunction.instance.evaluate(ve, EC)).getNumberValue();
assertEquals(41544.0, numberValue, 0);
Date actDate = DateUtil.getJavaDate(numberValue);
assertEquals(expDate, actDate);
}
use of org.apache.poi.ss.formula.eval.StringEval in project poi by apache.
the class TestWorkdayFunction method testFailWhenArgumentsAreNotDatesNorNumbers.
@Test
public void testFailWhenArgumentsAreNotDatesNorNumbers() {
ValueEval[] ve = { new StringEval("Potato"), new StringEval("Cucumber") };
assertEquals(VALUE_INVALID, WorkdayFunction.instance.evaluate(ve, EC));
}
Aggregations