use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.
the class TestText method testTextWithFractionFormatSecondArg.
@Test
public void testTextWithFractionFormatSecondArg() {
ValueEval numArg = new NumberEval(321.321);
ValueEval formatArg = new StringEval("# #/#");
ValueEval[] args = { numArg, formatArg };
ValueEval result = TextFunction.TEXT.evaluate(args, -1, (short) -1);
ValueEval testResult = new StringEval("321 1/3");
assertEquals(testResult.toString(), result.toString());
formatArg = new StringEval("# #/##");
args[1] = formatArg;
result = TextFunction.TEXT.evaluate(args, -1, (short) -1);
testResult = new StringEval("321 26/81");
assertEquals(testResult.toString(), result.toString());
formatArg = new StringEval("#/##");
args[1] = formatArg;
result = TextFunction.TEXT.evaluate(args, -1, (short) -1);
testResult = new StringEval("26027/81");
assertEquals(testResult.toString(), result.toString());
}
use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.
the class TestTrim method testUnusualArgs.
/**
* Valid cases where text arg is not exactly a string
*/
public void testUnusualArgs() {
// text (first) arg type is number, other args are strings with fractional digits
confirmTrim(new NumberEval(123456), "123456");
confirmTrim(BoolEval.FALSE, "FALSE");
confirmTrim(BoolEval.TRUE, "TRUE");
confirmTrim(BlankEval.instance, "");
}
use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.
the class TestTrunc method testTruncWithStringArg.
public void testTruncWithStringArg() {
ValueEval strArg = new StringEval("abc");
ValueEval[] args = { strArg, new NumberEval(2) };
ValueEval result = NumericFunction.TRUNC.evaluate(args, -1, (short) -1);
assertEquals(ErrorEval.VALUE_INVALID, result);
}
use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.
the class TestRoundFuncs method testRoundDownWithStringArg.
@Test
public void testRoundDownWithStringArg() {
ValueEval strArg = new StringEval("abc");
ValueEval[] args = { strArg, new NumberEval(2) };
ValueEval result = NumericFunction.ROUNDDOWN.evaluate(args, -1, (short) -1);
assertEquals(ErrorEval.VALUE_INVALID, result);
}
use of org.apache.poi.ss.formula.eval.NumberEval in project poi by apache.
the class TestRoundFuncs method testRoundUpWithStringArg.
@Test
public void testRoundUpWithStringArg() {
ValueEval strArg = new StringEval("abc");
ValueEval[] args = { strArg, new NumberEval(2) };
ValueEval result = NumericFunction.ROUNDUP.evaluate(args, -1, (short) -1);
assertEquals(ErrorEval.VALUE_INVALID, result);
}
Aggregations