add crude line-coverage tests for setDebugEvaluationOutputForNextEval and setIgnoreMissingWorkbooks

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1751841 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2016-07-07 23:00:07 +00:00
parent dd32e6b5b5
commit bb7da64c25
2 changed files with 39 additions and 10 deletions

View File

@ -113,6 +113,16 @@ public final class WorkbookEvaluator {
private boolean _ignoreMissingWorkbooks = false; private boolean _ignoreMissingWorkbooks = false;
/**
* whether print detailed messages about the next formula evaluation
*/
private boolean dbgEvaluationOutputForNextEval = false;
// special logger for formula evaluation output (because of possibly very large output)
private final POILogger EVAL_LOG = POILogFactory.getLogger("POI.FormulaEval");
// current indent level for evalution; negative value for no output
private int dbgEvaluationOutputIndent = -1;
/** /**
* @param udfFinder pass <code>null</code> for default (AnalysisToolPak only) * @param udfFinder pass <code>null</code> for default (AnalysisToolPak only)
*/ */
@ -408,17 +418,8 @@ public final class WorkbookEvaluator {
} }
/**
* whether print detailed messages about the next formula evaluation
*/
private boolean dbgEvaluationOutputForNextEval = false;
// special logger for formula evaluation output (because of possibly very large output)
private final POILogger EVAL_LOG = POILogFactory.getLogger("POI.FormulaEval");
// current indent level for evalution; negative value for no output
private int dbgEvaluationOutputIndent = -1;
// visibility raised for testing // visibility raised for testing
@Internal
/* package */ ValueEval evaluateFormula(OperationEvaluationContext ec, Ptg[] ptgs) { /* package */ ValueEval evaluateFormula(OperationEvaluationContext ec, Ptg[] ptgs) {
String dbgIndentStr = ""; // always init. to non-null just for defensive avoiding NPE String dbgIndentStr = ""; // always init. to non-null just for defensive avoiding NPE

View File

@ -18,7 +18,9 @@
package org.apache.poi.ss.formula; package org.apache.poi.ss.formula;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame; import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import java.io.IOException; import java.io.IOException;
@ -302,6 +304,32 @@ public class TestWorkbookEvaluator {
wb.close(); wb.close();
} }
@Test
public void testIgnoreMissingWorkbooks() {
// TODO: update this test for meaningful functional behavior
WorkbookEvaluator evaluator = new WorkbookEvaluator(null, null, null);
assertFalse(evaluator.isIgnoreMissingWorkbooks());
evaluator.setIgnoreMissingWorkbooks(true);
assertTrue(evaluator.isIgnoreMissingWorkbooks());
evaluator.setIgnoreMissingWorkbooks(false);
assertFalse(evaluator.isIgnoreMissingWorkbooks());
}
@Test
public void testDebugEvaluationOutputForNextEval() {
// TODO: update this test for meaningful functional behavior
WorkbookEvaluator evaluator = new WorkbookEvaluator(null, null, null);
assertFalse(evaluator.isDebugEvaluationOutputForNextEval());
evaluator.setDebugEvaluationOutputForNextEval(true);
assertTrue(evaluator.isDebugEvaluationOutputForNextEval());
evaluator.setDebugEvaluationOutputForNextEval(false);
assertFalse(evaluator.isDebugEvaluationOutputForNextEval());
}
// Test IF-Equals Formula Evaluation (bug 58591) // Test IF-Equals Formula Evaluation (bug 58591)