aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/ss/formula
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2015-01-09 16:51:02 +0000
committerDominik Stadler <centic@apache.org>2015-01-09 16:51:02 +0000
commitffdf1ba216d753eb9aaab5b7cdf1a63c9929aea6 (patch)
tree7430f911bd0aa2c0f939806eb53dfe332270f651 /src/testcases/org/apache/poi/ss/formula
parentef2ca85280d91621abf5a7fc27a15081519743aa (diff)
downloadpoi-ffdf1ba216d753eb9aaab5b7cdf1a63c9929aea6.tar.gz
poi-ffdf1ba216d753eb9aaab5b7cdf1a63c9929aea6.zip
Bug 57196: Resolve RefEval to it's inner ValueEval in Hex2Dec
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1650597 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/ss/formula')
-rw-r--r--src/testcases/org/apache/poi/ss/formula/functions/TestHex2Dec.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestHex2Dec.java b/src/testcases/org/apache/poi/ss/formula/functions/TestHex2Dec.java
index 7c04157416..b7ca30cd51 100644
--- a/src/testcases/org/apache/poi/ss/formula/functions/TestHex2Dec.java
+++ b/src/testcases/org/apache/poi/ss/formula/functions/TestHex2Dec.java
@@ -18,6 +18,12 @@
package org.apache.poi.ss.formula.functions;
import junit.framework.TestCase;
+
+import org.apache.poi.hssf.usermodel.HSSFEvaluationWorkbook;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.formula.IStabilityClassifier;
+import org.apache.poi.ss.formula.OperationEvaluationContext;
+import org.apache.poi.ss.formula.WorkbookEvaluator;
import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.formula.eval.NumberEval;
import org.apache.poi.ss.formula.eval.StringEval;
@@ -57,4 +63,49 @@ public final class TestHex2Dec extends TestCase {
confirmValueError("not a valid octal number","GGGGGGG", ErrorEval.NUM_ERROR);
confirmValueError("not a valid octal number","3.14159", ErrorEval.NUM_ERROR);
}
+
+ public void testEvalOperationEvaluationContext() {
+ OperationEvaluationContext ctx = createContext();
+
+ ValueEval[] args = new ValueEval[] { ctx.getRefEval(0, 0) };
+ ValueEval result = new Hex2Dec().evaluate(args, ctx);
+
+ assertEquals(NumberEval.class, result.getClass());
+ assertEquals("0", ((NumberEval) result).getStringValue());
+ }
+
+ public void testEvalOperationEvaluationContextFails() {
+ OperationEvaluationContext ctx = createContext();
+
+ ValueEval[] args = new ValueEval[] { ctx.getRefEval(0, 0), ctx.getRefEval(0, 0) };
+ ValueEval result = new Hex2Dec().evaluate(args, ctx);
+
+ assertEquals(ErrorEval.class, result.getClass());
+ assertEquals(ErrorEval.VALUE_INVALID, result);
+ }
+
+ private OperationEvaluationContext createContext() {
+ HSSFWorkbook wb = new HSSFWorkbook();
+ wb.createSheet();
+ HSSFEvaluationWorkbook workbook = HSSFEvaluationWorkbook.create(wb);
+ WorkbookEvaluator workbookEvaluator = new WorkbookEvaluator(workbook, new IStabilityClassifier() {
+
+ public boolean isCellFinal(int sheetIndex, int rowIndex, int columnIndex) {
+ return true;
+ }
+ }, null);
+ OperationEvaluationContext ctx = new OperationEvaluationContext(workbookEvaluator,
+ workbook, 0, 0, 0, null);
+ return ctx;
+ }
+
+ public void testRefs() {
+ OperationEvaluationContext ctx = createContext();
+
+ ValueEval[] args = new ValueEval[] { ctx.getRefEval(0, 0) };
+ ValueEval result = new Hex2Dec().evaluate(args, -1, -1);
+
+ assertEquals(NumberEval.class, result.getClass());
+ assertEquals("0", ((NumberEval) result).getStringValue());
+ }
}