use of org.apache.poi.ss.formula.OperationEvaluationContext in project poi by apache.
the class TestBin2Dec method createContext.
private OperationEvaluationContext createContext() {
HSSFWorkbook wb = new HSSFWorkbook();
wb.createSheet();
HSSFEvaluationWorkbook workbook = HSSFEvaluationWorkbook.create(wb);
WorkbookEvaluator workbookEvaluator = new WorkbookEvaluator(workbook, new IStabilityClassifier() {
@Override
public boolean isCellFinal(int sheetIndex, int rowIndex, int columnIndex) {
return true;
}
}, null);
OperationEvaluationContext ctx = new OperationEvaluationContext(workbookEvaluator, workbook, 0, 0, 0, null);
return ctx;
}
use of org.apache.poi.ss.formula.OperationEvaluationContext in project poi by apache.
the class TestDec2Hex method testWithErrorPlaces.
public void testWithErrorPlaces() {
OperationEvaluationContext ctx = createContext();
ValueEval[] args = new ValueEval[] { ctx.getRefEval(0, 0), ErrorEval.NULL_INTERSECTION };
ValueEval result = new Dec2Hex().evaluate(args, -1, -1);
assertEquals(ErrorEval.class, result.getClass());
assertEquals(ErrorEval.NULL_INTERSECTION, result);
}
use of org.apache.poi.ss.formula.OperationEvaluationContext in project poi by apache.
the class TestDec2Bin method testWithPlaces.
public void testWithPlaces() {
OperationEvaluationContext ctx = createContext();
ValueEval[] args = new ValueEval[] { ctx.getRefEval(0, 0), ctx.getRefEval(0, 1) };
ValueEval result = new Dec2Bin().evaluate(args, ctx);
assertEquals("Had: " + result, StringEval.class, result.getClass());
// TODO: documentation and behavior do not match here!
assertEquals("1101", ((StringEval) result).getStringValue());
}
use of org.apache.poi.ss.formula.OperationEvaluationContext in project poi by apache.
the class TestDec2Hex method testWithNegativePlaces.
public void testWithNegativePlaces() {
OperationEvaluationContext ctx = createContext();
ValueEval[] args = new ValueEval[] { ctx.getRefEval(0, 0), ctx.getRefEval(0, 2) };
ValueEval result = new Dec2Hex().evaluate(args, -1, -1);
assertEquals(ErrorEval.class, result.getClass());
assertEquals(ErrorEval.NUM_ERROR, result);
}
use of org.apache.poi.ss.formula.OperationEvaluationContext in project poi by apache.
the class TestDec2Hex method testWithTooManyParamsIntInt.
public void testWithTooManyParamsIntInt() {
OperationEvaluationContext ctx = createContext();
ValueEval[] args = new ValueEval[] { ctx.getRefEval(0, 0), ctx.getRefEval(0, 1), ctx.getRefEval(0, 1) };
ValueEval result = new Dec2Hex().evaluate(args, -1, -1);
assertEquals(ErrorEval.class, result.getClass());
assertEquals(ErrorEval.VALUE_INVALID, result);
}
Aggregations