From: Yegor Kozlov Date: Sat, 24 Jul 2010 11:33:59 +0000 (+0000) Subject: added a failing unit test for bug #49612 X-Git-Tag: REL_3_7_BETA2~22 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=74ff0ab72f629cdf16a9fcc1bb694dc2b39c1da0;p=poi.git added a failing unit test for bug #49612 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@978848 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestUnfixedBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestUnfixedBugs.java index cd7ae1c7b4..f794cd2b5d 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestUnfixedBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestUnfixedBugs.java @@ -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 index 0000000000..c31b62a132 Binary files /dev/null and b/test-data/spreadsheet/49612.xls differ