You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by jo...@apache.org on 2009/01/27 20:02:13 UTC

svn commit: r738188 - in /poi/trunk/src: documentation/content/xdocs/ java/org/apache/poi/hssf/record/formula/eval/ testcases/org/apache/poi/hssf/record/formula/eval/

Author: josh
Date: Tue Jan 27 19:02:13 2009
New Revision: 738188

URL: http://svn.apache.org/viewvc?rev=738188&view=rev
Log:
Fix for bug 46613 - evaluator should perform case insensitive string comparisons

Modified:
    poi/trunk/src/documentation/content/xdocs/changes.xml
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/eval/RelationalOperationEval.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/eval/TestEqualEval.java

Modified: poi/trunk/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/changes.xml?rev=738188&r1=738187&r2=738188&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Tue Jan 27 19:02:13 2009
@@ -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>

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=738188&r1=738187&r2=738188&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Tue Jan 27 19:02:13 2009
@@ -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>

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/eval/RelationalOperationEval.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/eval/RelationalOperationEval.java?rev=738188&r1=738187&r2=738188&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/eval/RelationalOperationEval.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/eval/RelationalOperationEval.java Tue Jan 27 19:02:13 2009
@@ -97,7 +97,7 @@
 			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;
 		}

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/eval/TestEqualEval.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/eval/TestEqualEval.java?rev=738188&r1=738187&r2=738188&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/eval/TestEqualEval.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/eval/TestEqualEval.java Tue Jan 27 19:02:13 2009
@@ -23,7 +23,7 @@
 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 @@
 		}
 		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();
+	}
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org