From: PJ Fanning Date: Wed, 29 Dec 2021 22:00:43 +0000 (+0000) Subject: fix tests X-Git-Tag: REL_5_2_0~30 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8210bdb0c866e1d9f56f25b2495c5d0518a01cbf;p=poi.git fix tests git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1896513 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/poi-ooxml/src/test/java/org/apache/poi/ss/tests/formula/functions/TestVlookup.java b/poi-ooxml/src/test/java/org/apache/poi/ss/tests/formula/functions/TestVlookup.java index 753e2046d2..15d0dedd90 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/ss/tests/formula/functions/TestVlookup.java +++ b/poi-ooxml/src/test/java/org/apache/poi/ss/tests/formula/functions/TestVlookup.java @@ -80,8 +80,8 @@ class TestVlookup { Cell cell = row.createCell(0); cell.setCellFormula("vlookup(A2,B1:B5,2,false)"); - CreationHelper crateHelper = wb.getCreationHelper(); - FormulaEvaluator eval = crateHelper.createFormulaEvaluator(); + CreationHelper createHelper = wb.getCreationHelper(); + FormulaEvaluator eval = createHelper.createFormulaEvaluator(); CellValue value = eval.evaluate(cell); assertFalse(value.getBooleanValue()); @@ -97,8 +97,8 @@ class TestVlookup { Cell cell = row.createCell(0); cell.setCellFormula("vlookup(A2,B1:B5,2,)"); - CreationHelper crateHelper = wb.getCreationHelper(); - FormulaEvaluator eval = crateHelper.createFormulaEvaluator(); + CreationHelper createHelper = wb.getCreationHelper(); + FormulaEvaluator eval = createHelper.createFormulaEvaluator(); CellValue value = eval.evaluate(cell); assertFalse(value.getBooleanValue()); @@ -114,8 +114,8 @@ class TestVlookup { Cell cell = row.createCell(0); cell.setCellFormula("vlookup(A2,B1:B5,,)"); - CreationHelper crateHelper = wb.getCreationHelper(); - FormulaEvaluator eval = crateHelper.createFormulaEvaluator(); + CreationHelper createHelper = wb.getCreationHelper(); + FormulaEvaluator eval = createHelper.createFormulaEvaluator(); CellValue value = eval.evaluate(cell); assertFalse(value.getBooleanValue()); @@ -131,8 +131,8 @@ class TestVlookup { Cell cell = row.createCell(0); cell.setCellFormula("vlookup(A2,,,)"); - CreationHelper crateHelper = wb.getCreationHelper(); - FormulaEvaluator eval = crateHelper.createFormulaEvaluator(); + CreationHelper createHelper = wb.getCreationHelper(); + FormulaEvaluator eval = createHelper.createFormulaEvaluator(); CellValue value = eval.evaluate(cell); assertFalse(value.getBooleanValue()); diff --git a/poi/src/main/java/org/apache/poi/ss/formula/OperatorEnum.java b/poi/src/main/java/org/apache/poi/ss/formula/OperatorEnum.java index 3eeea4eebe..a68d662e0e 100644 --- a/poi/src/main/java/org/apache/poi/ss/formula/OperatorEnum.java +++ b/poi/src/main/java/org/apache/poi/ss/formula/OperatorEnum.java @@ -131,8 +131,7 @@ enum OperatorEnum { if (v1 == null) { return true; // non-null not equal null, returns true } - // need to avoid instanceof, to work around a 1.6 compiler bug - if (cellValue.getClass() == String.class) { + if (cellValue instanceof String) { return cellValue.toString().compareToIgnoreCase(v1.toString()) == 0; } return cellValue.compareTo(v1) != 0; diff --git a/poi/src/main/java/org/apache/poi/ss/formula/functions/LookupUtils.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/LookupUtils.java index fa21d33531..648250beca 100644 --- a/poi/src/main/java/org/apache/poi/ss/formula/functions/LookupUtils.java +++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/LookupUtils.java @@ -123,9 +123,8 @@ public final class LookupUtils { @Override public Integer next() { - pos++; - if (pos > getSize()) throw new NoSuchElementException(); - return pos; + if (!hasNext()) throw new NoSuchElementException(); + return pos++; } }; }