diff options
author | Josh Micich <josh@apache.org> | 2009-01-27 19:02:13 +0000 |
---|---|---|
committer | Josh Micich <josh@apache.org> | 2009-01-27 19:02:13 +0000 |
commit | 7aa965d079344d296edb339a77bbf2f9a6ce1fb8 (patch) | |
tree | da9761fe1efc4fa4e200b9d512994617c84da83c | |
parent | ed4b7878bb7ea5552f9a53feef7664fcd6a2ba91 (diff) | |
download | poi-7aa965d079344d296edb339a77bbf2f9a6ce1fb8.tar.gz poi-7aa965d079344d296edb339a77bbf2f9a6ce1fb8.zip |
Fix for bug 46613 - evaluator should perform case insensitive string comparisons
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@738188 13f79535-47bb-0310-9956-ffa450edef68
4 files changed, 29 insertions, 2 deletions
diff --git a/src/documentation/content/xdocs/changes.xml b/src/documentation/content/xdocs/changes.xml index 37b8514b0f..61605b2776 100644 --- a/src/documentation/content/xdocs/changes.xml +++ b/src/documentation/content/xdocs/changes.xml @@ -37,6 +37,7 @@ <!-- Don't forget to update status.xml too! --> <release version="3.5-beta5" date="2008-??-??"> + <action dev="POI-DEVELOPERS" type="fix">46613 - Fixed evaluator to perform case insensitive string comparisons</action> <action dev="POI-DEVELOPERS" type="add">46544 - command line interface for hssf ExcelExtractor</action> <action dev="POI-DEVELOPERS" type="fix">46547 - Allow addition of conditional formatting after data validation</action> <action dev="POI-DEVELOPERS" type="fix">46548 - Page Settings Block fixes - continued PLS records and PSB in sheet sub-streams</action> diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 8c937f51b9..595dfa1690 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ <!-- Don't forget to update changes.xml too! --> <changes> <release version="3.5-beta5" date="2008-??-??"> + <action dev="POI-DEVELOPERS" type="fix">46613 - Fixed evaluator to perform case insensitive string comparisons</action> <action dev="POI-DEVELOPERS" type="add">46544 - command line interface for hssf ExcelExtractor</action> <action dev="POI-DEVELOPERS" type="fix">46547 - Allow addition of conditional formatting after data validation</action> <action dev="POI-DEVELOPERS" type="fix">46548 - Page Settings Block fixes - continued PLS records and PSB in sheet sub-streams</action> diff --git a/src/java/org/apache/poi/hssf/record/formula/eval/RelationalOperationEval.java b/src/java/org/apache/poi/hssf/record/formula/eval/RelationalOperationEval.java index a1397f07f4..9dee4bc1e0 100644 --- a/src/java/org/apache/poi/hssf/record/formula/eval/RelationalOperationEval.java +++ b/src/java/org/apache/poi/hssf/record/formula/eval/RelationalOperationEval.java @@ -97,7 +97,7 @@ public abstract class RelationalOperationEval implements OperationEval { if (vb instanceof StringEval) { StringEval sA = (StringEval) va; StringEval sB = (StringEval) vb; - return sA.getStringValue().compareTo(sB.getStringValue()); + return sA.getStringValue().compareToIgnoreCase(sB.getStringValue()); } return 1; } diff --git a/src/testcases/org/apache/poi/hssf/record/formula/eval/TestEqualEval.java b/src/testcases/org/apache/poi/hssf/record/formula/eval/TestEqualEval.java index d1b1db0d16..92f603923c 100644 --- a/src/testcases/org/apache/poi/hssf/record/formula/eval/TestEqualEval.java +++ b/src/testcases/org/apache/poi/hssf/record/formula/eval/TestEqualEval.java @@ -23,7 +23,7 @@ import junit.framework.TestCase; import org.apache.poi.hssf.record.formula.functions.EvalFactory;
/**
- * Test for unary plus operator evaluator.
+ * Test for {@link EqualEval}
*
* @author Josh Micich
*/
@@ -66,4 +66,29 @@ public final class TestEqualEval extends TestCase { }
assertTrue(be.getBooleanValue());
}
+
+ /**
+ * Test for bug 46613 (observable at svn r737248)
+ */
+ public void testStringInsensitive_bug46613() {
+ if (!evalStringCmp("abc", "aBc", EqualEval.instance)) {
+ throw new AssertionFailedError("Identified bug 46613");
+ }
+ assertTrue(evalStringCmp("abc", "aBc", EqualEval.instance));
+ assertTrue(evalStringCmp("ABC", "azz", LessThanEval.instance));
+ assertTrue(evalStringCmp("abc", "AZZ", LessThanEval.instance));
+ assertTrue(evalStringCmp("ABC", "aaa", GreaterThanEval.instance));
+ assertTrue(evalStringCmp("abc", "AAA", GreaterThanEval.instance));
+ }
+
+ private static boolean evalStringCmp(String a, String b, OperationEval cmpOp) {
+ Eval[] args = {
+ new StringEval(a),
+ new StringEval(b),
+ };
+ Eval result = cmpOp.evaluate(args, 10, (short)20);
+ assertEquals(BoolEval.class, result.getClass());
+ BoolEval be = (BoolEval) result;
+ return be.getBooleanValue();
+ }
}
|