diff options
author | Nick Burch <nick@apache.org> | 2014-10-18 20:53:50 +0000 |
---|---|---|
committer | Nick Burch <nick@apache.org> | 2014-10-18 20:53:50 +0000 |
commit | ac777eb7c89488dc08e16577a4ff3e2bf4970edc (patch) | |
tree | 019d8a474088a662fd1172b6464f127c89fcd4c5 | |
parent | 9517e9254e415875016f556a7e7fe436453a7c9e (diff) | |
download | poi-ac777eb7c89488dc08e16577a4ff3e2bf4970edc.tar.gz poi-ac777eb7c89488dc08e16577a4ff3e2bf4970edc.zip |
Finish unit tests for stackoverflow #26437323 - POI works fine already!
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1632842 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java | 106 |
1 files changed, 100 insertions, 6 deletions
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java index 0f20edc8f4..378b24526f 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java @@ -528,9 +528,9 @@ public abstract class BaseTestBugzillaIssues { } /** - * =ISNUMBER(SEARCH("*AM*",A1)) not evaluating properly + * =ISNUMBER(SEARCH("AM",A1)) evaluation */ - //@Test + @Test public void stackoverflow26437323() throws Exception { Workbook wb = _testDataProvider.createWorkbook(); Sheet s = wb.createSheet(); @@ -566,17 +566,111 @@ public abstract class BaseTestBugzillaIssues { // Now, check ISNUMBER / ISTEXT / ISNONTEXT - // TODO + cf.setCellFormula("ISNUMBER(A1)"); + cf = evaluateCell(wb, cf); + assertEquals(true, cf.getBooleanCellValue()); + + cf.setCellFormula("ISNUMBER(B1)"); + cf = evaluateCell(wb, cf); + assertEquals(false, cf.getBooleanCellValue()); + + cf.setCellFormula("ISNUMBER(C1)"); + cf = evaluateCell(wb, cf); + assertEquals(false, cf.getBooleanCellValue()); + + cf.setCellFormula("ISNUMBER(D1)"); + cf = evaluateCell(wb, cf); + assertEquals(false, cf.getBooleanCellValue()); + + cf.setCellFormula("ISNUMBER(E1)"); + cf = evaluateCell(wb, cf); + assertEquals(false, cf.getBooleanCellValue()); + + + cf.setCellFormula("ISTEXT(A1)"); + cf = evaluateCell(wb, cf); + assertEquals(false, cf.getBooleanCellValue()); + + cf.setCellFormula("ISTEXT(B1)"); + cf = evaluateCell(wb, cf); + assertEquals(true, cf.getBooleanCellValue()); + + cf.setCellFormula("ISTEXT(C1)"); + cf = evaluateCell(wb, cf); + assertEquals(true, cf.getBooleanCellValue()); + + cf.setCellFormula("ISTEXT(D1)"); + cf = evaluateCell(wb, cf); + assertEquals(false, cf.getBooleanCellValue()); + + cf.setCellFormula("ISTEXT(E1)"); + cf = evaluateCell(wb, cf); + assertEquals(false, cf.getBooleanCellValue()); + + + cf.setCellFormula("ISNONTEXT(A1)"); + cf = evaluateCell(wb, cf); + assertEquals(true, cf.getBooleanCellValue()); + + cf.setCellFormula("ISNONTEXT(B1)"); + cf = evaluateCell(wb, cf); + assertEquals(false, cf.getBooleanCellValue()); + + cf.setCellFormula("ISNONTEXT(C1)"); + cf = evaluateCell(wb, cf); + assertEquals(false, cf.getBooleanCellValue()); + + cf.setCellFormula("ISNONTEXT(D1)"); + cf = evaluateCell(wb, cf); + assertEquals(true, cf.getBooleanCellValue()); + + cf.setCellFormula("ISNONTEXT(E1)"); + cf = evaluateCell(wb, cf); + assertEquals(true, cf.getBooleanCellValue()); // Blank and Null the same + // Next up, SEARCH on its own - // TODO + cf.setCellFormula("SEARCH(\"am\", A1)"); + cf = evaluateCell(wb, cf); + assertEquals(ErrorConstants.ERROR_VALUE, cf.getErrorCellValue()); + + cf.setCellFormula("SEARCH(\"am\", B1)"); + cf = evaluateCell(wb, cf); + assertEquals(19, (int)cf.getNumericCellValue()); + + cf.setCellFormula("SEARCH(\"am\", C1)"); + cf = evaluateCell(wb, cf); + assertEquals(ErrorConstants.ERROR_VALUE, cf.getErrorCellValue()); + + cf.setCellFormula("SEARCH(\"am\", D1)"); + cf = evaluateCell(wb, cf); + assertEquals(ErrorConstants.ERROR_VALUE, cf.getErrorCellValue()); + // Finally, bring it all together - // TODO + cf.setCellFormula("ISNUMBER(SEARCH(\"am\", A1))"); + cf = evaluateCell(wb, cf); + assertEquals(false, cf.getBooleanCellValue()); + + cf.setCellFormula("ISNUMBER(SEARCH(\"am\", B1))"); + cf = evaluateCell(wb, cf); + assertEquals(true, cf.getBooleanCellValue()); + + cf.setCellFormula("ISNUMBER(SEARCH(\"am\", C1))"); + cf = evaluateCell(wb, cf); + assertEquals(false, cf.getBooleanCellValue()); + + cf.setCellFormula("ISNUMBER(SEARCH(\"am\", D1))"); + cf = evaluateCell(wb, cf); + assertEquals(false, cf.getBooleanCellValue()); + + cf.setCellFormula("ISNUMBER(SEARCH(\"am\", E1))"); + cf = evaluateCell(wb, cf); + assertEquals(false, cf.getBooleanCellValue()); } private Cell evaluateCell(Workbook wb, Cell c) { Sheet s = c.getSheet(); - wb.getCreationHelper().createFormulaEvaluator().evaluate(c); + wb.getCreationHelper().createFormulaEvaluator().evaluateFormulaCell(c); return s.getRow(c.getRowIndex()).getCell(c.getColumnIndex()); } } |