From 74ff0ab72f629cdf16a9fcc1bb694dc2b39c1da0 Mon Sep 17 00:00:00 2001 From: Yegor Kozlov Date: Sat, 24 Jul 2010 11:33:59 +0000 Subject: [PATCH] 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 --- .../poi/hssf/usermodel/TestUnfixedBugs.java | 33 ++++++++++++++++++ test-data/spreadsheet/49612.xls | Bin 0 -> 5632 bytes 2 files changed, 33 insertions(+) create mode 100755 test-data/spreadsheet/49612.xls 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 0000000000000000000000000000000000000000..c31b62a13218344f82a47c3914064b9222479829 GIT binary patch literal 5632 zcmeHKO>A355T3Q49j762{@V06eQ{FPb{vzW5)Jgnj?*Fm3XM#wsv^iZt&^H0b#Vd| z4q#HawNeEqB#`J4BntEZ7m$)0QiUjRpm0D9H@Hxwa%*kAnfG2|8@sqwD?#x-eY^W+ zXLj~yc6RpiH!WAsf4Xs*O444kQ!Zam&H}nZogt~2$c764=kocyK_o)8mi|L4a1&$Y z{bOj@LHb`S7^U&elTQ2T1j-D(j2*8&t%Jo_D`SV4?qaV%v?w_} z%Eh@uXD;neFVQA0LG)>4jrVZk4HM!j8!s1cStHN{xB*-N)B>~uZ2-?{EwB#g0M-K=fQ`T=U^B1<=mfR`I?x4pfNr1% z*amok?SK#P0|B5H2m*aT2zU_Su@9If&%Ksze+6(Bj01~xypvS#f)zL&^t12lx^J_n zqPJyq`H8k99shz($6?*Dog>MqbVh$7{mM-GMg3lYXJZkQ+@qX`Rcx^Hcab;2 zE_vGQJ=k_R|5$jxkbIBWG|{QuxvfKJ<2dJgiU{9X$vu)cAy@Rd$owRf0a*K2;LpEy z4qBPyP{Z(WDN4Z4l(d53ZnnN(QE#WV8GagP($nMV4t96<$Njs;eb&#ozfy%!4JXX ztSGhQSM*xKqIy;Gs_F0l%b>k zMI)pXZUh@0Lma{N7UUdHxah_Qe|$GOF&2&sJs|X6$rpr@EzrIVs|rs`ucKv2Ye)Rh zh2UYt>p7U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