aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/hssf
diff options
context:
space:
mode:
authorJosh Micich <josh@apache.org>2008-05-26 18:02:23 +0000
committerJosh Micich <josh@apache.org>2008-05-26 18:02:23 +0000
commit7c1e1f24785294d90c8dc76a1b033a07aeeb4d9d (patch)
treede429282c8ef17013faa0761262e74acb4431b1b /src/testcases/org/apache/poi/hssf
parentf8c3f05e7363534971537c37417718152db7b039 (diff)
downloadpoi-7c1e1f24785294d90c8dc76a1b033a07aeeb4d9d.tar.gz
poi-7c1e1f24785294d90c8dc76a1b033a07aeeb4d9d.zip
Follow-on fix for bug 42564 (r653668). Array elements are stored internally column by column.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@660256 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/hssf')
-rw-r--r--src/testcases/org/apache/poi/hssf/data/ex42564-elementOrder.xlsbin0 -> 16384 bytes
-rw-r--r--src/testcases/org/apache/poi/hssf/record/formula/TestArrayPtg.java29
2 files changed, 24 insertions, 5 deletions
diff --git a/src/testcases/org/apache/poi/hssf/data/ex42564-elementOrder.xls b/src/testcases/org/apache/poi/hssf/data/ex42564-elementOrder.xls
new file mode 100644
index 0000000000..3c49fc2572
--- /dev/null
+++ b/src/testcases/org/apache/poi/hssf/data/ex42564-elementOrder.xls
Binary files differ
diff --git a/src/testcases/org/apache/poi/hssf/record/formula/TestArrayPtg.java b/src/testcases/org/apache/poi/hssf/record/formula/TestArrayPtg.java
index 16f80bb791..39464b5e03 100644
--- a/src/testcases/org/apache/poi/hssf/record/formula/TestArrayPtg.java
+++ b/src/testcases/org/apache/poi/hssf/record/formula/TestArrayPtg.java
@@ -19,8 +19,10 @@ package org.apache.poi.hssf.record.formula;
import java.util.Arrays;
+import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.record.TestcaseRecordInputStream;
import org.apache.poi.hssf.record.UnicodeString;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
@@ -77,7 +79,7 @@ public final class TestArrayPtg extends TestCase {
}
/**
- * make sure constant elements are stored row by row
+ * Excel stores array elements column by column. This test makes sure POI does the same.
*/
public void testElementOrdering() {
ArrayPtg ptg = new ArrayPtgV(new TestcaseRecordInputStream(ArrayPtgV.sid, ENCODED_PTG_DATA));
@@ -86,10 +88,27 @@ public final class TestArrayPtg extends TestCase {
assertEquals(2, ptg.getRowCount());
assertEquals(0, ptg.getValueIndex(0, 0));
- assertEquals(1, ptg.getValueIndex(1, 0));
- assertEquals(2, ptg.getValueIndex(2, 0));
- assertEquals(3, ptg.getValueIndex(0, 1));
- assertEquals(4, ptg.getValueIndex(1, 1));
+ assertEquals(2, ptg.getValueIndex(1, 0));
+ assertEquals(4, ptg.getValueIndex(2, 0));
+ assertEquals(1, ptg.getValueIndex(0, 1));
+ assertEquals(3, ptg.getValueIndex(1, 1));
assertEquals(5, ptg.getValueIndex(2, 1));
}
+
+ /**
+ * Test for a bug which was temporarily introduced by the fix for bug 42564.
+ * A spreadsheet was added to make the ordering clearer.
+ */
+ public void testElementOrderingInSpreadsheet() {
+ HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("ex42564-elementOrder.xls");
+
+ // The formula has an array with 3 rows and 5 column
+ String formula = wb.getSheetAt(0).getRow(0).getCell((short)0).getCellFormula();
+ // TODO - These number literals should not have '.0'. Excel has different number rendering rules
+
+ if (formula.equals("SUM({1.0,6.0,11.0;2.0,7.0,12.0;3.0,8.0,13.0;4.0,9.0,14.0;5.0,10.0,15.0})")) {
+ throw new AssertionFailedError("Identified bug 42564 b");
+ }
+ assertEquals("SUM({1.0,2.0,3.0;4.0,5.0,6.0;7.0,8.0,9.0;10.0,11.0,12.0;13.0,14.0,15.0})", formula);
+ }
}