]> source.dussan.org Git - poi.git/commitdiff
added a failing unit test for bug #49612
authorYegor Kozlov <yegor@apache.org>
Sat, 24 Jul 2010 11:33:59 +0000 (11:33 +0000)
committerYegor Kozlov <yegor@apache.org>
Sat, 24 Jul 2010 11:33:59 +0000 (11:33 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@978848 13f79535-47bb-0310-9956-ffa450edef68

src/testcases/org/apache/poi/hssf/usermodel/TestUnfixedBugs.java
test-data/spreadsheet/49612.xls [new file with mode: 0755]

index cd7ae1c7b4aa70e5e180fa26b5cec7fe2e2a4ad8..f794cd2b5d2a4a16b6a09938e28cb31e60e19d2c 100644 (file)
@@ -23,6 +23,10 @@ import junit.framework.TestCase;
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.hssf.record.RecordFormatException;
 
+import java.io.IOException;
+import java.io.FileInputStream;
+import java.io.File;
+
 /**
  * @author aviks
  * 
@@ -46,4 +50,33 @@ public final class TestUnfixedBugs extends TestCase {
                        throw e;
                }
        }
+
+    public void test49612() throws IOException {
+        HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("49612.xls");
+        HSSFSheet sh = wb.getSheetAt(0);
+        HSSFRow row = sh.getRow(0);
+        HSSFCell c1 = row.getCell(2);
+        HSSFCell d1 = row.getCell(3);
+        HSSFCell e1 = row.getCell(2);
+
+        assertEquals("SUM(BOB+JIM)", c1.getCellFormula());
+
+        // Problem 1: java.lang.ArrayIndexOutOfBoundsException in org.apache.poi.hssf.model.LinkTable$ExternalBookBlock.getNameText
+        assertEquals("SUM('49612.xls'!BOB+'49612.xls'!JIM)", d1.getCellFormula());
+
+        //Problem 2
+        //junit.framework.ComparisonFailure:
+        //Expected :SUM('49612.xls'!BOB+'49612.xls'!JIM)
+        //Actual   :SUM(BOB+JIM)
+        assertEquals("SUM('49612.xls'!BOB+'49612.xls'!JIM)", e1.getCellFormula());
+
+        HSSFFormulaEvaluator eval = new HSSFFormulaEvaluator(wb);
+        assertEquals("evaluating c1", 30., eval.evaluate(c1).getNumberValue());
+
+        //Problem 3:  java.lang.RuntimeException: Unexpected arg eval type (org.apache.poi.hssf.record.formula.eval.NameXEval)
+        assertEquals("evaluating d1", 30., eval.evaluate(d1).getNumberValue());
+
+        assertEquals("evaluating e1", 30., eval.evaluate(e1).getNumberValue());
+    }
+    
 }
diff --git a/test-data/spreadsheet/49612.xls b/test-data/spreadsheet/49612.xls
new file mode 100755 (executable)
index 0000000..c31b62a
Binary files /dev/null and b/test-data/spreadsheet/49612.xls differ