aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/hssf
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2008-03-07 12:06:18 +0000
committerNick Burch <nick@apache.org>2008-03-07 12:06:18 +0000
commitc532455620f42677f3365284257f6682be0abe8d (patch)
treeb340754e39f413a041d5c62b4ddb94513bc8f0b6 /src/testcases/org/apache/poi/hssf
parent25916b25bcaec47977867ed5b526aa490c3fc18d (diff)
downloadpoi-c532455620f42677f3365284257f6682be0abe8d.tar.gz
poi-c532455620f42677f3365284257f6682be0abe8d.zip
Patch largely from Josh from bug #44539 - Support for area references in formulas of rows >= 32768
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@634630 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/hssf')
-rw-r--r--src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java37
-rw-r--r--src/testcases/org/apache/poi/hssf/record/formula/TestAreaPtg.java14
2 files changed, 27 insertions, 24 deletions
diff --git a/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java b/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java
index 7b42bf333f..f922e75d82 100644
--- a/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java
+++ b/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -21,6 +20,7 @@ package org.apache.poi.hssf.model;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
+import org.apache.poi.hssf.model.FormulaParser.FormulaParseException;
import org.apache.poi.hssf.record.formula.AbstractFunctionPtg;
import org.apache.poi.hssf.record.formula.AddPtg;
import org.apache.poi.hssf.record.formula.AreaPtg;
@@ -59,18 +59,8 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
* Some tests are also done in scratchpad, if they need
* HSSFFormulaEvaluator, which is there
*/
-public class TestFormulaParser extends TestCase {
+public final class TestFormulaParser extends TestCase {
- public TestFormulaParser(String name) {
- super(name);
- }
- public void setUp(){
-
- }
-
- public void tearDown() {
-
- }
/**
* @return parsed token array already confirmed not <code>null</code>
*/
@@ -831,10 +821,27 @@ public class TestFormulaParser extends TestCase {
try {
parseFormula(formula);
throw new AssertionFailedError("expected parse exception");
- } catch (RuntimeException e) {
- // TODO - catch more specific exception
+ } catch (FormulaParseException e) {
// expected during successful test
- return;
+ assertNotNull(e.getMessage());
+ } catch (RuntimeException e) {
+ e.printStackTrace();
+ fail("Wrong exception:" + e.getMessage());
+ }
+ }
+
+ public void testSetFormulaWithRowBeyond32768_Bug44539() {
+
+ HSSFWorkbook wb = new HSSFWorkbook();
+ HSSFSheet sheet = wb.createSheet();
+ wb.setSheetName(0, "Sheet1");
+
+ HSSFRow row = sheet.createRow(0);
+ HSSFCell cell = row.createCell((short)0);
+ cell.setCellFormula("SUM(A32769:A32770)");
+ if("SUM(A-32767:A-32766)".equals(cell.getCellFormula())) {
+ fail("Identified bug 44539");
}
+ assertEquals("SUM(A32769:A32770)", cell.getCellFormula());
}
}
diff --git a/src/testcases/org/apache/poi/hssf/record/formula/TestAreaPtg.java b/src/testcases/org/apache/poi/hssf/record/formula/TestAreaPtg.java
index 522a5bcf28..3a7f2f29a4 100644
--- a/src/testcases/org/apache/poi/hssf/record/formula/TestAreaPtg.java
+++ b/src/testcases/org/apache/poi/hssf/record/formula/TestAreaPtg.java
@@ -27,15 +27,12 @@ import org.apache.poi.hssf.model.FormulaParser;
*
* @author Dmitriy Kumshayev
*/
-public class TestAreaPtg extends TestCase
-{
+public final class TestAreaPtg extends TestCase {
AreaPtg relative;
AreaPtg absolute;
- protected void setUp() throws Exception
- {
- super.setUp();
+ protected void setUp() {
short firstRow=5;
short lastRow=13;
short firstCol=7;
@@ -64,10 +61,9 @@ public class TestAreaPtg extends TestCase
}
- public void resetColumns(AreaPtg aptg)
- {
- short fc = aptg.getFirstColumn();
- short lc = aptg.getLastColumn();
+ private static void resetColumns(AreaPtg aptg) {
+ int fc = aptg.getFirstColumn();
+ int lc = aptg.getLastColumn();
aptg.setFirstColumn(fc);
aptg.setLastColumn(lc);
assertEquals(fc , aptg.getFirstColumn() );