poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r700916 - in /poi/trunk/src: java/org/apache/poi/ss/formula/CellCacheEntry.java testcases/org/apache/poi/ss/formula/AllSSFormulaTests.java testcases/org/apache/poi/ss/formula/TestCellCacheEntry.java
Date Wed, 01 Oct 2008 20:56:22 GMT
Author: josh
Date: Wed Oct  1 13:56:21 2008
New Revision: 700916

URL: http://svn.apache.org/viewvc?rev=700916&view=rev
Log:
Fixed bug in CellCacheEntry (support for caching blank evaluation results)

Added:
    poi/trunk/src/testcases/org/apache/poi/ss/formula/TestCellCacheEntry.java
Modified:
    poi/trunk/src/java/org/apache/poi/ss/formula/CellCacheEntry.java
    poi/trunk/src/testcases/org/apache/poi/ss/formula/AllSSFormulaTests.java

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/CellCacheEntry.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/CellCacheEntry.java?rev=700916&r1=700915&r2=700916&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/CellCacheEntry.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/CellCacheEntry.java Wed Oct  1 13:56:21 2008
@@ -20,6 +20,7 @@
 import java.util.HashSet;
 import java.util.Set;
 
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
 import org.apache.poi.hssf.record.formula.eval.BoolEval;
 import org.apache.poi.hssf.record.formula.eval.ErrorEval;
 import org.apache.poi.hssf.record.formula.eval.NumberEval;
@@ -60,6 +61,9 @@
 			// value type is changing
 			return false;
 		}
+		if (a == BlankEval.INSTANCE) {
+			return b == a;
+		}
 		if (cls == NumberEval.class) {
 			return ((NumberEval)a).getNumberValue() == ((NumberEval)b).getNumberValue();
 		}

Modified: poi/trunk/src/testcases/org/apache/poi/ss/formula/AllSSFormulaTests.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/formula/AllSSFormulaTests.java?rev=700916&r1=700915&r2=700916&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/formula/AllSSFormulaTests.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/formula/AllSSFormulaTests.java Wed Oct  1 13:56:21
2008
@@ -26,9 +26,10 @@
  */
 public final class AllSSFormulaTests {
     public static Test suite() {
-        TestSuite result = new TestSuite(AllSSFormulaTests.class.getName());
-        result.addTestSuite(TestEvaluationCache.class);
-        result.addTestSuite(TestWorkbookEvaluator.class);
-        return result;
-    }
+		TestSuite result = new TestSuite(AllSSFormulaTests.class.getName());
+		result.addTestSuite(TestCellCacheEntry.class);
+		result.addTestSuite(TestEvaluationCache.class);
+		result.addTestSuite(TestWorkbookEvaluator.class);
+		return result;
+	}
 }

Added: poi/trunk/src/testcases/org/apache/poi/ss/formula/TestCellCacheEntry.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/formula/TestCellCacheEntry.java?rev=700916&view=auto
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/formula/TestCellCacheEntry.java (added)
+++ poi/trunk/src/testcases/org/apache/poi/ss/formula/TestCellCacheEntry.java Wed Oct  1 13:56:21
2008
@@ -0,0 +1,53 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.ss.formula;
+
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
+/**
+ * Tests {@link CellCacheEntry}.
+ *
+ * @author Josh Micich
+ */
+public class TestCellCacheEntry extends TestCase {
+
+	public void testBasic() {
+		CellCacheEntry cce = new CellCacheEntry();
+		cce.updatePlainValue(new NumberEval(42.0));
+		ValueEval ve = cce.getValue();
+		assertEquals(42, ((NumberEval)ve).getNumberValue(), 0.0);
+		
+		cce.setFormulaResult(new NumberEval(10.0), new CellLocation[] { });
+	}
+
+	public void testBlank() {
+		CellCacheEntry cce = new CellCacheEntry();
+		cce.updatePlainValue(BlankEval.INSTANCE);
+		try {
+			cce.updatePlainValue(BlankEval.INSTANCE);
+		} catch (IllegalStateException e) {
+			// bug was visible around svn r700356
+			throw new AssertionFailedError("cache entry does not handle blank values properly");
+		}
+	}
+}



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


Mime
View raw message