From a012cfa423a456910d163d3893f946a06c0cf775 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sat, 14 Aug 2021 00:28:37 +0000 Subject: [PATCH] tidy up eval git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1892322 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/ss/formula/functions/LookupUtils.java | 7 ++----- .../usermodel/BaseTestConditionalFormatting.java | 15 +++++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) 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 bc371ec44c..d6a92b3e1f 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 @@ -305,14 +305,11 @@ public final class LookupUtils { StringEval se = (StringEval) other; String stringValue = se.getStringValue(); - if (_wildCardPattern != null) { + if (_wildCardPattern != null && (_isMatchFunction || !_matchExact)) { Matcher matcher = _wildCardPattern.matcher(stringValue); boolean matches = matcher.matches(); - if (_isMatchFunction || - !_matchExact) { - return CompareResult.valueOf(matches); - } + return CompareResult.valueOf(matches); } return CompareResult.valueOf(_value.compareToIgnoreCase(stringValue)); diff --git a/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java b/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java index 4d3954fa78..eec63048e6 100644 --- a/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java +++ b/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestConditionalFormatting.java @@ -53,6 +53,9 @@ public abstract class BaseTestConditionalFormatting { protected abstract void assertColor(String hexExpected, Color actual); + protected int defaultDataBarMinLength() { return 0; } + protected int defaultDataBarMaxLength() { return 100; } + @Test void testBasic() throws Throwable { try (Workbook wb = _testDataProvider.createWorkbook()) { @@ -764,8 +767,8 @@ public abstract class BaseTestConditionalFormatting { assertNotNull(databar); assertFalse(databar.isIconOnly()); assertTrue(databar.isLeftToRight()); - assertEquals(0, databar.getWidthMin()); - assertEquals(100, databar.getWidthMax()); + assertEquals(defaultDataBarMinLength(), databar.getWidthMin()); + assertEquals(defaultDataBarMaxLength(), databar.getWidthMax()); assertColor(color, databar.getColor()); @@ -1177,8 +1180,8 @@ public abstract class BaseTestConditionalFormatting { assertFalse(dbFmt.isIconOnly()); assertTrue(dbFmt.isLeftToRight()); - assertEquals(0, dbFmt.getWidthMin()); - assertEquals(100, dbFmt.getWidthMax()); + assertEquals(defaultDataBarMinLength(), dbFmt.getWidthMin()); + assertEquals(defaultDataBarMaxLength(), dbFmt.getWidthMax()); assertColor(colorHex, dbFmt.getColor()); dbFmt.getMinThreshold().setRangeType(RangeType.MIN); @@ -1201,8 +1204,8 @@ public abstract class BaseTestConditionalFormatting { assertFalse(dbFmt.isIconOnly()); assertTrue(dbFmt.isLeftToRight()); - assertEquals(0, dbFmt.getWidthMin()); - assertEquals(100, dbFmt.getWidthMax()); + assertEquals(defaultDataBarMinLength(), dbFmt.getWidthMin()); + assertEquals(defaultDataBarMaxLength(), dbFmt.getWidthMax()); assertColor(colorHex, dbFmt.getColor()); assertEquals(RangeType.MIN, dbFmt.getMinThreshold().getRangeType());