From: PJ Fanning Date: Sun, 5 Dec 2021 18:54:58 +0000 (+0000) Subject: fix broken xlookup test X-Git-Tag: REL_5_2_0~124 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c390436c9a1821bb51d2dd125d4b521e06726606;p=poi.git fix broken xlookup test git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1895602 13f79535-47bb-0310-9956-ffa450edef68 --- 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 43ad217a5b..04ec1004b3 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 @@ -760,7 +760,10 @@ public final class LookupUtils { break; } if (result.isTypeMismatch()) { - handleMidValueTypeMismatch(lookupComparer, vector, bsi, i, reverse); + int newIdx = handleMidValueTypeMismatch(lookupComparer, vector, bsi, i, reverse); + if (newIdx >= 0) { + return newIdx; + } } else if (reverse) { bsi.narrowSearch(i, result.isGreaterThan()); } else { diff --git a/poi/src/test/java/org/apache/poi/ss/formula/atp/TestXLookupFunction.java b/poi/src/test/java/org/apache/poi/ss/formula/atp/TestXLookupFunction.java index ab66de7c5e..0f03e35eef 100644 --- a/poi/src/test/java/org/apache/poi/ss/formula/atp/TestXLookupFunction.java +++ b/poi/src/test/java/org/apache/poi/ss/formula/atp/TestXLookupFunction.java @@ -127,8 +127,7 @@ public class TestXLookupFunction { HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb); HSSFCell cell = wb.getSheetAt(0).getRow(1).createCell(6); assertDouble(fe, cell, "XLOOKUP(E2,C2:C7,B2:B7,0,1,-2)", 0.37); - //TODO next assertion is not working and needs investigation - //assertDouble(fe, cell, "XLOOKUP(9700,C2:C7,B2:B7,0,0,-2)", 0.1); + assertDouble(fe, cell, "XLOOKUP(9700,C2:C7,B2:B7,0,0,-2)", 0.1); assertDouble(fe, cell, "XLOOKUP(39474,C2:C7,B2:B7,0,0,-2)", 0); } }