aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/ss
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2020-05-16 13:05:58 +0000
committerDominik Stadler <centic@apache.org>2020-05-16 13:05:58 +0000
commitff919eb0e4b25a7ba9a97ad6c8fdc64a381a96b0 (patch)
tree54bc82470039c3e55d836fa66045ccfe227b6566 /src/testcases/org/apache/poi/ss
parentd2ad752e1ca157ce6b4918bbed003c6491d7e651 (diff)
downloadpoi-ff919eb0e4b25a7ba9a97ad6c8fdc64a381a96b0.tar.gz
poi-ff919eb0e4b25a7ba9a97ad6c8fdc64a381a96b0.zip
Bug 64393: Adjust relational operators to handle MissingArgEval correctly
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1877815 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/ss')
-rw-r--r--src/testcases/org/apache/poi/ss/formula/eval/TestMissingArgEval.java62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/ss/formula/eval/TestMissingArgEval.java b/src/testcases/org/apache/poi/ss/formula/eval/TestMissingArgEval.java
index e99c8e1cce..122882d609 100644
--- a/src/testcases/org/apache/poi/ss/formula/eval/TestMissingArgEval.java
+++ b/src/testcases/org/apache/poi/ss/formula/eval/TestMissingArgEval.java
@@ -18,6 +18,8 @@
package org.apache.poi.ss.formula.eval;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import java.io.IOException;
@@ -55,6 +57,66 @@ public final class TestMissingArgEval {
}
@Test
+ public void testCompareMissingArgs() throws IOException {
+ try (HSSFWorkbook wb = new HSSFWorkbook()) {
+ HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
+ HSSFSheet sheet = wb.createSheet("Sheet1");
+ HSSFCell cell = sheet.createRow(0).createCell(0);
+
+ cell.setCellFormula("iferror(0/0,)<0");
+ fe.clearAllCachedResultValues();
+ CellValue cv = fe.evaluate(cell);
+ assertFalse(cv.getBooleanValue());
+
+ cell.setCellFormula("iferror(0/0,)<=0");
+ fe.clearAllCachedResultValues();
+ cv = fe.evaluate(cell);
+ assertTrue(cv.getBooleanValue());
+
+ cell.setCellFormula("iferror(0/0,)=0");
+ fe.clearAllCachedResultValues();
+ cv = fe.evaluate(cell);
+ assertTrue(cv.getBooleanValue());
+
+ cell.setCellFormula("iferror(0/0,)>=0");
+ fe.clearAllCachedResultValues();
+ cv = fe.evaluate(cell);
+ assertTrue(cv.getBooleanValue());
+
+ cell.setCellFormula("iferror(0/0,)>0");
+ fe.clearAllCachedResultValues();
+ cv = fe.evaluate(cell);
+ assertFalse(cv.getBooleanValue());
+
+ // invert above for code coverage
+ cell.setCellFormula("0<iferror(0/0,)");
+ fe.clearAllCachedResultValues();
+ cv = fe.evaluate(cell);
+ assertFalse(cv.getBooleanValue());
+
+ cell.setCellFormula("0<=iferror(0/0,)");
+ fe.clearAllCachedResultValues();
+ cv = fe.evaluate(cell);
+ assertTrue(cv.getBooleanValue());
+
+ cell.setCellFormula("0=iferror(0/0,)");
+ fe.clearAllCachedResultValues();
+ cv = fe.evaluate(cell);
+ assertTrue(cv.getBooleanValue());
+
+ cell.setCellFormula("0>=iferror(0/0,)");
+ fe.clearAllCachedResultValues();
+ cv = fe.evaluate(cell);
+ assertTrue(cv.getBooleanValue());
+
+ cell.setCellFormula("0>iferror(0/0,)");
+ fe.clearAllCachedResultValues();
+ cv = fe.evaluate(cell);
+ assertFalse(cv.getBooleanValue());
+ }
+ }
+
+ @Test
public void testCountFuncs() throws IOException {
try (HSSFWorkbook wb = new HSSFWorkbook()) {
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);