You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2008/02/14 17:01:16 UTC
svn commit: r627788 [2/2] - in /poi/trunk/src: documentation/content/xdocs/
java/org/apache/poi/hssf/model/ java/org/apache/poi/hssf/record/formula/
scratchpad/src/org/apache/poi/hssf/record/formula/eval/
scratchpad/src/org/apache/poi/hssf/record/formu...
Added: poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestMatch.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestMatch.java?rev=627788&view=auto
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestMatch.java (added)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestMatch.java Thu Feb 14 08:01:10 2008
@@ -0,0 +1,184 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hssf.record.formula.functions;
+
+import junit.framework.TestCase;
+
+import org.apache.poi.hssf.record.formula.AreaPtg;
+import org.apache.poi.hssf.record.formula.eval.Area2DEval;
+import org.apache.poi.hssf.record.formula.eval.BoolEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.StringEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+
+/**
+ * Test cases for MATCH()
+ *
+ * @author Josh Micich
+ */
+public final class TestMatch extends TestCase {
+ /** less than or equal to */
+ private static final NumberEval MATCH_LARGEST_LTE = new NumberEval(1);
+ private static final NumberEval MATCH_EXACT = new NumberEval(0);
+ /** greater than or equal to */
+ private static final NumberEval MATCH_SMALLEST_GTE = new NumberEval(-1);
+
+
+ private static Eval invokeMatch(Eval lookup_value, Eval lookup_array, Eval match_type) {
+ Eval[] args = { lookup_value, lookup_array, match_type, };
+ return new Match().evaluate(args, -1, (short)-1);
+ }
+ private static void confirmInt(int expected, Eval actualEval) {
+ if(!(actualEval instanceof NumericValueEval)) {
+ fail("Expected numeric result");
+ }
+ NumericValueEval nve = (NumericValueEval)actualEval;
+ assertEquals(expected, nve.getNumberValue(), 0);
+ }
+
+ public void testSimpleNumber() {
+
+ ValueEval[] values = {
+ new NumberEval(4),
+ new NumberEval(5),
+ new NumberEval(10),
+ new NumberEval(10),
+ new NumberEval(25),
+ };
+
+ AreaPtg areaPtg = new AreaPtg("A1:A5");
+ Area2DEval ae = new Area2DEval(areaPtg, values);
+
+
+ confirmInt(2, invokeMatch(new NumberEval(5), ae, MATCH_LARGEST_LTE));
+ confirmInt(2, invokeMatch(new NumberEval(5), ae, MATCH_EXACT));
+ confirmInt(4, invokeMatch(new NumberEval(10), ae, MATCH_LARGEST_LTE));
+ confirmInt(3, invokeMatch(new NumberEval(10), ae, MATCH_EXACT));
+ confirmInt(4, invokeMatch(new NumberEval(20), ae, MATCH_LARGEST_LTE));
+ assertEquals(ErrorEval.NA, invokeMatch(new NumberEval(20), ae, MATCH_EXACT));
+ }
+
+ public void testReversedNumber() {
+
+ ValueEval[] values = {
+ new NumberEval(25),
+ new NumberEval(10),
+ new NumberEval(10),
+ new NumberEval(10),
+ new NumberEval(4),
+ };
+
+ AreaPtg areaPtg = new AreaPtg("A1:A5");
+ Area2DEval ae = new Area2DEval(areaPtg, values);
+
+
+ confirmInt(2, invokeMatch(new NumberEval(10), ae, MATCH_SMALLEST_GTE));
+ confirmInt(2, invokeMatch(new NumberEval(10), ae, MATCH_EXACT));
+ confirmInt(4, invokeMatch(new NumberEval(9), ae, MATCH_SMALLEST_GTE));
+ confirmInt(1, invokeMatch(new NumberEval(20), ae, MATCH_SMALLEST_GTE));
+ assertEquals(ErrorEval.NA, invokeMatch(new NumberEval(20), ae, MATCH_EXACT));
+ assertEquals(ErrorEval.NA, invokeMatch(new NumberEval(26), ae, MATCH_SMALLEST_GTE));
+ }
+
+ public void testSimpleString() {
+
+ ValueEval[] values = {
+ new StringEval("Albert"),
+ new StringEval("Charles"),
+ new StringEval("Ed"),
+ new StringEval("Greg"),
+ new StringEval("Ian"),
+ };
+
+ AreaPtg areaPtg = new AreaPtg("A1:A5");
+ Area2DEval ae = new Area2DEval(areaPtg, values);
+
+ // Note String comparisons are case insensitive
+ confirmInt(3, invokeMatch(new StringEval("Ed"), ae, MATCH_LARGEST_LTE));
+ confirmInt(3, invokeMatch(new StringEval("eD"), ae, MATCH_LARGEST_LTE));
+ confirmInt(3, invokeMatch(new StringEval("Ed"), ae, MATCH_EXACT));
+ confirmInt(3, invokeMatch(new StringEval("ed"), ae, MATCH_EXACT));
+ confirmInt(4, invokeMatch(new StringEval("Hugh"), ae, MATCH_LARGEST_LTE));
+ assertEquals(ErrorEval.NA, invokeMatch(new StringEval("Hugh"), ae, MATCH_EXACT));
+ }
+
+ public void testSimpleBoolean() {
+
+ ValueEval[] values = {
+ BoolEval.FALSE,
+ BoolEval.FALSE,
+ BoolEval.TRUE,
+ BoolEval.TRUE,
+ };
+
+ AreaPtg areaPtg = new AreaPtg("A1:A4");
+ Area2DEval ae = new Area2DEval(areaPtg, values);
+
+ // Note String comparisons are case insensitive
+ confirmInt(2, invokeMatch(BoolEval.FALSE, ae, MATCH_LARGEST_LTE));
+ confirmInt(1, invokeMatch(BoolEval.FALSE, ae, MATCH_EXACT));
+ confirmInt(4, invokeMatch(BoolEval.TRUE, ae, MATCH_LARGEST_LTE));
+ confirmInt(3, invokeMatch(BoolEval.TRUE, ae, MATCH_EXACT));
+ }
+
+ public void testHeterogeneous() {
+
+ ValueEval[] values = {
+ new NumberEval(4),
+ BoolEval.FALSE,
+ new NumberEval(5),
+ new StringEval("Albert"),
+ BoolEval.FALSE,
+ BoolEval.TRUE,
+ new NumberEval(10),
+ new StringEval("Charles"),
+ new StringEval("Ed"),
+ new NumberEval(10),
+ new NumberEval(25),
+ BoolEval.TRUE,
+ new StringEval("Ed"),
+ };
+
+ AreaPtg areaPtg = new AreaPtg("A1:A13");
+ Area2DEval ae = new Area2DEval(areaPtg, values);
+
+ assertEquals(ErrorEval.NA, invokeMatch(new StringEval("Aaron"), ae, MATCH_LARGEST_LTE));
+
+ confirmInt(5, invokeMatch(BoolEval.FALSE, ae, MATCH_LARGEST_LTE));
+ confirmInt(2, invokeMatch(BoolEval.FALSE, ae, MATCH_EXACT));
+ confirmInt(3, invokeMatch(new NumberEval(5), ae, MATCH_LARGEST_LTE));
+ confirmInt(3, invokeMatch(new NumberEval(5), ae, MATCH_EXACT));
+
+ confirmInt(8, invokeMatch(new StringEval("CHARLES"), ae, MATCH_EXACT));
+
+ confirmInt(4, invokeMatch(new StringEval("Ben"), ae, MATCH_LARGEST_LTE));
+
+ confirmInt(13, invokeMatch(new StringEval("ED"), ae, MATCH_LARGEST_LTE));
+ confirmInt(9, invokeMatch(new StringEval("ED"), ae, MATCH_EXACT));
+
+ confirmInt(13, invokeMatch(new StringEval("Hugh"), ae, MATCH_LARGEST_LTE));
+ assertEquals(ErrorEval.NA, invokeMatch(new StringEval("Hugh"), ae, MATCH_EXACT));
+
+ confirmInt(11, invokeMatch(new NumberEval(30), ae, MATCH_LARGEST_LTE));
+ confirmInt(12, invokeMatch(BoolEval.TRUE, ae, MATCH_LARGEST_LTE));
+ }
+
+}
Propchange: poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestMatch.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestMatch.java
------------------------------------------------------------------------------
svn:executable = *
Added: poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestRoundFuncs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestRoundFuncs.java?rev=627788&view=auto
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestRoundFuncs.java (added)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestRoundFuncs.java Thu Feb 14 08:01:10 2008
@@ -0,0 +1,49 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.StringEval;
+
+import junit.framework.TestCase;
+
+/**
+ * Test cases for ROUND(), ROUNDUP(), ROUNDDOWN()
+ *
+ * @author Josh Micich
+ */
+public final class TestRoundFuncs extends TestCase {
+ public void testRounddownWithStringArg() {
+
+ Eval strArg = new StringEval("abc");
+ Eval[] args = { strArg, new NumberEval(2), };
+ Eval result = new Rounddown().evaluate(args, -1, (short)-1);
+ assertEquals(ErrorEval.VALUE_INVALID, result);
+ }
+
+ public void testRoundupWithStringArg() {
+
+ Eval strArg = new StringEval("abc");
+ Eval[] args = { strArg, new NumberEval(2), };
+ Eval result = new Roundup().evaluate(args, -1, (short)-1);
+ assertEquals(ErrorEval.VALUE_INVALID, result);
+ }
+
+}
Propchange: poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestRoundFuncs.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestRoundFuncs.java
------------------------------------------------------------------------------
svn:executable = *
Added: poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestSumproduct.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestSumproduct.java?rev=627788&view=auto
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestSumproduct.java (added)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestSumproduct.java Thu Feb 14 08:01:10 2008
@@ -0,0 +1,120 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.ReferencePtg;
+import org.apache.poi.hssf.record.formula.eval.AreaEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
+import org.apache.poi.hssf.record.formula.eval.Ref2DEval;
+import org.apache.poi.hssf.record.formula.eval.RefEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+
+import junit.framework.TestCase;
+
+/**
+ * Test cases for SUMPRODUCT()
+ *
+ * @author Josh Micich
+ */
+public final class TestSumproduct extends TestCase {
+
+ private static Eval invokeSumproduct(Eval[] args) {
+ // srcCellRow and srcCellColumn are ignored by SUMPRODUCT
+ return new Sumproduct().evaluate(args, -1, (short)-1);
+ }
+ private static void confirmDouble(double expected, Eval actualEval) {
+ if(!(actualEval instanceof NumericValueEval)) {
+ fail("Expected numeric result");
+ }
+ NumericValueEval nve = (NumericValueEval)actualEval;
+ assertEquals(expected, nve.getNumberValue(), 0);
+ }
+
+ public void testScalarSimple() {
+
+ RefEval refEval = new Ref2DEval(new ReferencePtg("A1"), new NumberEval(3), true);
+ Eval[] args = {
+ refEval,
+ new NumberEval(2),
+ };
+ Eval result = invokeSumproduct(args);
+ confirmDouble(6D, result);
+ }
+
+
+ public void testAreaSimple() {
+
+ AreaEval aeA = EvalFactory.createAreaEval("A1:A3", 1, 3);
+ AreaEval aeB = EvalFactory.createAreaEval("B1:B3", 1, 3);
+ ValueEval[] aValues = aeA.getValues();
+ ValueEval[] bValues = aeB.getValues();
+ aValues[0] = new NumberEval(2);
+ aValues[1] = new NumberEval(4);
+ aValues[2] = new NumberEval(5);
+ bValues[0] = new NumberEval(3);
+ bValues[1] = new NumberEval(6);
+ bValues[2] = new NumberEval(7);
+
+ Eval[] args = { aeA, aeB, };
+ Eval result = invokeSumproduct(args);
+ confirmDouble(65D, result);
+ }
+
+ /**
+ * For scalar products, the terms may be 1x1 area refs
+ */
+ public void testOneByOneArea() {
+
+ AreaEval ae = EvalFactory.createAreaEval("A1:A1", 1, 1);
+ ae.getValues()[0] = new NumberEval(7);
+
+ Eval[] args = {
+ ae,
+ new NumberEval(2),
+ };
+ Eval result = invokeSumproduct(args);
+ confirmDouble(14D, result);
+ }
+
+
+ public void testMismatchAreaDimensions() {
+
+ AreaEval aeA = EvalFactory.createAreaEval("A1:A3", 1, 3);
+ AreaEval aeB = EvalFactory.createAreaEval("B1:D1", 3, 1);
+
+ Eval[] args;
+ args = new Eval[] { aeA, aeB, };
+ assertEquals(ErrorEval.VALUE_INVALID, invokeSumproduct(args));
+
+ args = new Eval[] { aeA, new NumberEval(5), };
+ assertEquals(ErrorEval.VALUE_INVALID, invokeSumproduct(args));
+ }
+
+ public void testAreaWithErrorCell() {
+ AreaEval aeA = EvalFactory.createAreaEval("A1:A2", 1, 2);
+ AreaEval aeB = EvalFactory.createAreaEval("B1:B2", 1, 2);
+ aeB.getValues()[1] = ErrorEval.REF_INVALID;
+
+ Eval[] args = { aeA, aeB, };
+ assertEquals(ErrorEval.REF_INVALID, invokeSumproduct(args));
+ }
+
+}
Propchange: poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestSumproduct.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestSumproduct.java
------------------------------------------------------------------------------
svn:executable = *
Added: poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestTFunc.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestTFunc.java?rev=627788&view=auto
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestTFunc.java (added)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestTFunc.java Thu Feb 14 08:01:10 2008
@@ -0,0 +1,118 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.ReferencePtg;
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.BoolEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.Ref2DEval;
+import org.apache.poi.hssf.record.formula.eval.StringEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+
+import junit.framework.TestCase;
+
+/**
+ * Test cases for Excel function T()
+ *
+ * @author Josh Micich
+ */
+public final class TestTFunc extends TestCase {
+
+ /**
+ * @return the result of calling function T() with the specified argument
+ */
+ private static Eval invokeT(Eval arg) {
+ Eval[] args = { arg, };
+ Eval result = new T().evaluate(args, -1, (short)-1);
+ assertNotNull("result may never be null", result);
+ return result;
+ }
+ /**
+ * Simulates call: T(A1)
+ * where cell A1 has the specified innerValue
+ */
+ private Eval invokeTWithReference(ValueEval innerValue) {
+ Eval arg = new Ref2DEval(new ReferencePtg((short)1, (short)1, false, false), innerValue, true);
+ return invokeT(arg);
+ }
+
+ private static void confirmText(String text) {
+ Eval arg = new StringEval(text);
+ Eval eval = invokeT(arg);
+ StringEval se = (StringEval) eval;
+ assertEquals(text, se.getStringValue());
+ }
+
+ public void testTextValues() {
+
+ confirmText("abc");
+ confirmText("");
+ confirmText(" ");
+ confirmText("~");
+ confirmText("123");
+ confirmText("TRUE");
+ }
+
+ private static void confirmError(Eval arg) {
+ Eval eval = invokeT(arg);
+ assertTrue(arg == eval);
+ }
+
+ public void testErrorValues() {
+
+ confirmError(ErrorEval.VALUE_INVALID);
+ confirmError(ErrorEval.NA);
+ confirmError(ErrorEval.REF_INVALID);
+ }
+
+ private static void confirmString(Eval eval, String expected) {
+ assertTrue(eval instanceof StringEval);
+ assertEquals(expected, ((StringEval)eval).getStringValue());
+ }
+
+ private static void confirmOther(Eval arg) {
+ Eval eval = invokeT(arg);
+ confirmString(eval, "");
+ }
+
+ public void testOtherValues() {
+ confirmOther(new NumberEval(2));
+ confirmOther(BoolEval.FALSE);
+ confirmOther(BlankEval.INSTANCE); // can this particular case be verified?
+ }
+
+ public void testRefValues() {
+ Eval eval;
+
+ eval = invokeTWithReference(new StringEval("def"));
+ confirmString(eval, "def");
+ eval = invokeTWithReference(new StringEval(" "));
+ confirmString(eval, " ");
+
+ eval = invokeTWithReference(new NumberEval(2));
+ confirmString(eval, "");
+ eval = invokeTWithReference(BoolEval.TRUE);
+ confirmString(eval, "");
+
+ eval = invokeTWithReference(ErrorEval.NAME_INVALID);
+ assertTrue(eval == ErrorEval.NAME_INVALID);
+ }
+}
Propchange: poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestTFunc.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestTFunc.java
------------------------------------------------------------------------------
svn:executable = *
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/data/FormulaEvalTestData.xls
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/data/FormulaEvalTestData.xls?rev=627788&r1=627787&r2=627788&view=diff
==============================================================================
Binary files - no diff available.
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/data/TestDataValidation.xls
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/data/TestDataValidation.xls?rev=627788&r1=627787&r2=627788&view=diff
==============================================================================
Binary files - no diff available.
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java?rev=627788&r1=627787&r2=627788&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java Thu Feb 14 08:01:10 2008
@@ -18,6 +18,8 @@
package org.apache.poi.hssf.model;
+import java.util.List;
+
import junit.framework.TestCase;
import org.apache.poi.hssf.record.formula.AbstractFunctionPtg;
@@ -26,6 +28,7 @@
import org.apache.poi.hssf.record.formula.BoolPtg;
import org.apache.poi.hssf.record.formula.DividePtg;
import org.apache.poi.hssf.record.formula.EqualPtg;
+import org.apache.poi.hssf.record.formula.FuncPtg;
import org.apache.poi.hssf.record.formula.FuncVarPtg;
import org.apache.poi.hssf.record.formula.IntPtg;
import org.apache.poi.hssf.record.formula.LessEqualPtg;
@@ -397,7 +400,7 @@
public void testUnderscore() {
HSSFWorkbook wb = new HSSFWorkbook();
- wb.createSheet("Cash_Flow");;
+ wb.createSheet("Cash_Flow");
HSSFSheet sheet = wb.createSheet("Test");
HSSFRow row = sheet.createRow(0);
@@ -438,7 +441,7 @@
public void testExponentialInSheet() throws Exception {
HSSFWorkbook wb = new HSSFWorkbook();
- wb.createSheet("Cash_Flow");;
+ wb.createSheet("Cash_Flow");
HSSFSheet sheet = wb.createSheet("Test");
HSSFRow row = sheet.createRow(0);
@@ -514,7 +517,7 @@
public void testNumbers() {
HSSFWorkbook wb = new HSSFWorkbook();
- wb.createSheet("Cash_Flow");;
+ wb.createSheet("Cash_Flow");
HSSFSheet sheet = wb.createSheet("Test");
HSSFRow row = sheet.createRow(0);
@@ -553,7 +556,7 @@
public void testRanges() {
HSSFWorkbook wb = new HSSFWorkbook();
- wb.createSheet("Cash_Flow");;
+ wb.createSheet("Cash_Flow");
HSSFSheet sheet = wb.createSheet("Test");
HSSFRow row = sheet.createRow(0);
@@ -571,5 +574,19 @@
cell.setCellFormula("A1...A2");
formula = cell.getCellFormula();
assertEquals("A1:A2", formula);
- }
+ }
+
+ /**
+ * Test for bug observable at svn revision 618865 (5-Feb-2008)<br/>
+ * a formula consisting of a single no-arg function got rendered without the function braces
+ */
+ public void testToFormulaStringZeroArgFunction() {
+
+ Workbook book = Workbook.createWorkbook(); // not really used in this test
+
+ Ptg[] ptgs = {
+ new FuncPtg(10, 0),
+ };
+ assertEquals("NA()", FormulaParser.toFormulaString(book, ptgs));
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org