use of org.apache.poi.ss.formula.eval.StringEval in project poi by apache.
the class TestMatch method testInvalidMatchType.
public void testInvalidMatchType() {
ValueEval[] values = { new NumberEval(4), new NumberEval(5), new NumberEval(10), new NumberEval(10), new NumberEval(25) };
AreaEval ae = EvalFactory.createAreaEval("A1:A5", values);
confirmInt(2, invokeMatch(new NumberEval(5), ae, MATCH_LARGEST_LTE));
assertEquals("Should return #REF! for invalid match type", ErrorEval.REF_INVALID, invokeMatch(new StringEval("Ben"), ae, MATCH_INVALID));
}
use of org.apache.poi.ss.formula.eval.StringEval in project poi by apache.
the class TestMatch method testTildeString.
public void testTildeString() {
ValueEval[] values = { new StringEval("what?"), new StringEval("all*") };
AreaEval ae = EvalFactory.createAreaEval("A1:A2", values);
confirmInt(1, invokeMatch(new StringEval("what~?"), ae, MATCH_EXACT));
confirmInt(2, invokeMatch(new StringEval("all~*"), ae, MATCH_EXACT));
}
use of org.apache.poi.ss.formula.eval.StringEval in project poi by apache.
the class TestMid method testUnusualArgs.
/**
* Valid cases where args are not precisely (string, int, int) but can be resolved OK.
*/
public void testUnusualArgs() {
// startPos with fractional digits
confirmMid(new StringEval("galactic"), new NumberEval(3.1), new NumberEval(4), "lact");
// string startPos
confirmMid(new StringEval("galactic"), new StringEval("3"), new NumberEval(4), "lact");
// text (first) arg type is number, other args are strings with fractional digits
confirmMid(new NumberEval(123456), new StringEval("3.1"), new StringEval("2.9"), "34");
// startPos is 1x1 area ref, numChars is cell ref
AreaEval aeStart = EvalFactory.createAreaEval("A1:A1", new ValueEval[] { new NumberEval(2) });
RefEval reNumChars = EvalFactory.createRefEval("B1", new NumberEval(3));
confirmMid(new StringEval("galactic"), aeStart, reNumChars, "ala");
confirmMid(new StringEval("galactic"), new NumberEval(3.1), BlankEval.instance, "");
confirmMid(new StringEval("galactic"), new NumberEval(3), BoolEval.FALSE, "");
confirmMid(new StringEval("galactic"), new NumberEval(3), BoolEval.TRUE, "l");
confirmMid(BlankEval.instance, new NumberEval(3), BoolEval.TRUE, "");
}
use of org.apache.poi.ss.formula.eval.StringEval in project poi by apache.
the class TestMid method testErrors.
/**
* All sorts of ways to make MID return defined errors.
*/
public void testErrors() {
confirmMid(ErrorEval.NAME_INVALID, new NumberEval(3), new NumberEval(4), ErrorEval.NAME_INVALID);
confirmMid(new StringEval("galactic"), ErrorEval.NAME_INVALID, new NumberEval(4), ErrorEval.NAME_INVALID);
confirmMid(new StringEval("galactic"), new NumberEval(3), ErrorEval.NAME_INVALID, ErrorEval.NAME_INVALID);
confirmMid(new StringEval("galactic"), ErrorEval.DIV_ZERO, ErrorEval.NAME_INVALID, ErrorEval.DIV_ZERO);
confirmMid(new StringEval("galactic"), BlankEval.instance, new NumberEval(3.1), ErrorEval.VALUE_INVALID);
confirmMid(new StringEval("galactic"), new NumberEval(0), new NumberEval(4), ErrorEval.VALUE_INVALID);
confirmMid(new StringEval("galactic"), new NumberEval(1), new NumberEval(-1), ErrorEval.VALUE_INVALID);
}
use of org.apache.poi.ss.formula.eval.StringEval in project poi by apache.
the class TestCountFuncs method testCountA.
public void testCountA() {
ValueEval[] args;
args = new ValueEval[] { new NumberEval(0) };
confirmCountA(1, args);
args = new ValueEval[] { new NumberEval(0), new NumberEval(0), new StringEval("") };
confirmCountA(3, args);
args = new ValueEval[] { EvalFactory.createAreaEval("D2:F5", new ValueEval[12]) };
confirmCountA(12, args);
args = new ValueEval[] { EvalFactory.createAreaEval("D1:F5", new ValueEval[15]), EvalFactory.createRefEval("A1"), EvalFactory.createAreaEval("A1:G6", new ValueEval[42]), new NumberEval(0) };
confirmCountA(59, args);
}
Aggregations