View | Details | Raw Unified | Return to bug 64393
Collapse All | Expand All

(-)a/src/java/org/apache/poi/ss/formula/eval/RelationalOperationEval.java (-4 / +4 lines)
Lines 86-96 public abstract class RelationalOperationEval extends Fixed2ArgFunction implemen Link Here
86
	}
86
	}
87
87
88
	private static int doCompare(ValueEval va, ValueEval vb) {
88
	private static int doCompare(ValueEval va, ValueEval vb) {
89
		// special cases when one operand is blank
89
		// special cases when one operand is blank or missing
90
		if (va == BlankEval.instance) {
90
		if (va == BlankEval.instance || va instanceof MissingArgEval) {
91
			return compareBlank(vb);
91
			return compareBlank(vb);
92
		}
92
		}
93
		if (vb == BlankEval.instance) {
93
		if (vb == BlankEval.instance || vb instanceof MissingArgEval) {
94
			return -compareBlank(va);
94
			return -compareBlank(va);
95
		}
95
		}
96
96
Lines 131-137 public abstract class RelationalOperationEval extends Fixed2ArgFunction implemen Link Here
131
	}
131
	}
132
132
133
	private static int compareBlank(ValueEval v) {
133
	private static int compareBlank(ValueEval v) {
134
		if (v == BlankEval.instance) {
134
		if (v == BlankEval.instance || v instanceof MissingArgEval) {
135
			return 0;
135
			return 0;
136
		}
136
		}
137
		if (v instanceof BoolEval) {
137
		if (v instanceof BoolEval) {
(-)a/src/testcases/org/apache/poi/ss/formula/eval/TestMissingArgEval.java (+62 lines)
Lines 18-23 Link Here
18
package org.apache.poi.ss.formula.eval;
18
package org.apache.poi.ss.formula.eval;
19
19
20
import static org.junit.Assert.assertEquals;
20
import static org.junit.Assert.assertEquals;
21
import static org.junit.Assert.assertFalse;
22
import static org.junit.Assert.assertTrue;
21
23
22
import java.io.IOException;
24
import java.io.IOException;
23
25
Lines 54-59 public final class TestMissingArgEval { Link Here
54
		}
56
		}
55
	}
57
	}
56
58
59
	@Test
60
	public void testCompareMissingArgs() throws IOException {
61
		try (HSSFWorkbook wb = new HSSFWorkbook()) {
62
			HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
63
			HSSFSheet sheet = wb.createSheet("Sheet1");
64
			HSSFCell cell = sheet.createRow(0).createCell(0);
65
66
			cell.setCellFormula("iferror(0/0,)<0");
67
			fe.clearAllCachedResultValues();
68
			CellValue cv = fe.evaluate(cell);
69
			assertFalse(cv.getBooleanValue());
70
71
			cell.setCellFormula("iferror(0/0,)<=0");
72
			fe.clearAllCachedResultValues();
73
			cv = fe.evaluate(cell);
74
			assertTrue(cv.getBooleanValue());
75
76
			cell.setCellFormula("iferror(0/0,)=0");
77
			fe.clearAllCachedResultValues();
78
			cv = fe.evaluate(cell);
79
			assertTrue(cv.getBooleanValue());
80
81
			cell.setCellFormula("iferror(0/0,)>=0");
82
			fe.clearAllCachedResultValues();
83
			cv = fe.evaluate(cell);
84
			assertTrue(cv.getBooleanValue());
85
86
			cell.setCellFormula("iferror(0/0,)>0");
87
			fe.clearAllCachedResultValues();
88
			cv = fe.evaluate(cell);
89
			assertFalse(cv.getBooleanValue());
90
			
91
			// invert above for code coverage
92
			cell.setCellFormula("0<iferror(0/0,)");
93
            fe.clearAllCachedResultValues();
94
            cv = fe.evaluate(cell);
95
            assertFalse(cv.getBooleanValue());
96
97
            cell.setCellFormula("0<=iferror(0/0,)");
98
            fe.clearAllCachedResultValues();
99
            cv = fe.evaluate(cell);
100
            assertTrue(cv.getBooleanValue());
101
102
            cell.setCellFormula("0=iferror(0/0,)");
103
            fe.clearAllCachedResultValues();
104
            cv = fe.evaluate(cell);
105
            assertTrue(cv.getBooleanValue());
106
107
            cell.setCellFormula("0>=iferror(0/0,)");
108
            fe.clearAllCachedResultValues();
109
            cv = fe.evaluate(cell);
110
            assertTrue(cv.getBooleanValue());
111
112
            cell.setCellFormula("0>iferror(0/0,)");
113
            fe.clearAllCachedResultValues();
114
            cv = fe.evaluate(cell);
115
            assertFalse(cv.getBooleanValue());
116
		}
117
	}
118
57
	@Test
119
	@Test
58
	public void testCountFuncs() throws IOException {
120
	public void testCountFuncs() throws IOException {
59
		try (HSSFWorkbook wb = new HSSFWorkbook()) {
121
		try (HSSFWorkbook wb = new HSSFWorkbook()) {

Return to bug 64393