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 2008/10/23 23:42:05 UTC

svn commit: r707481 - in /poi/trunk/src: java/org/apache/poi/hssf/record/formula/AttrPtg.java testcases/org/apache/poi/hssf/record/formula/AllFormulaTests.java testcases/org/apache/poi/hssf/record/formula/TestAttrPtg.java

Author: josh
Date: Thu Oct 23 14:42:05 2008
New Revision: 707481

URL: http://svn.apache.org/viewvc?rev=707481&view=rev
Log:
fixed re-serialization of tAttrChoose

Added:
    poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestAttrPtg.java
Modified:
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/AttrPtg.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/AllFormulaTests.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/AttrPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/AttrPtg.java?rev=707481&r1=707480&r2=707481&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/AttrPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/AttrPtg.java Thu Oct 23 14:42:05 2008
@@ -221,15 +221,12 @@
         int[] jt = _jumpTable;
         if (jt != null) {
             int joff = offset+4;
-            LittleEndian.putUShort(array, joff, _chooseFuncOffset);
-            joff+=2;
             for (int i = 0; i < jt.length; i++) {
                 LittleEndian.putUShort(array, joff, jt[i]);
                 joff+=2;
             }
             LittleEndian.putUShort(array, joff, _chooseFuncOffset);
         }
-
     }
 
     public int getSize()

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/AllFormulaTests.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/AllFormulaTests.java?rev=707481&r1=707480&r2=707481&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/AllFormulaTests.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/AllFormulaTests.java Thu Oct 23 14:42:05 2008
@@ -41,6 +41,7 @@
 		result.addTestSuite(TestAreaErrPtg.class);
 		result.addTestSuite(TestAreaPtg.class);
 		result.addTestSuite(TestArrayPtg.class);
+		result.addTestSuite(TestAttrPtg.class);
 		result.addTestSuite(TestErrPtg.class);
 		result.addTestSuite(TestExternalFunctionFormulas.class);
 		result.addTestSuite(TestFormulaShifter.class);

Added: poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestAttrPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestAttrPtg.java?rev=707481&view=auto
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestAttrPtg.java (added)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestAttrPtg.java Thu Oct 23 14:42:05 2008
@@ -0,0 +1,50 @@
+/* ====================================================================
+   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.hssf.record.formula;
+
+import java.util.Arrays;
+
+import junit.framework.AssertionFailedError;
+
+import org.apache.poi.hssf.record.RecordInputStream;
+import org.apache.poi.hssf.record.TestcaseRecordInputStream;
+import org.apache.poi.util.HexRead;
+
+/**
+ * Tests for {@link AttrPtg}.
+ * 
+ * @author Josh Micich
+ */
+public final class TestAttrPtg extends AbstractPtgTestCase {
+
+	/**
+	 * Fix for bug visible around svn r706772.
+	 */
+	public void testReserializeAttrChoose() {
+		byte[] data = HexRead.readFromString("19, 04, 03, 00, 08, 00, 11, 00, 1A, 00, 23, 00");
+		RecordInputStream in = TestcaseRecordInputStream.createWithFakeSid(data);
+		Ptg[] ptgs = Ptg.readTokens(data.length, in);
+		byte[] data2 = new byte[data.length];
+		try {
+			Ptg.serializePtgs(ptgs, data2, 0);
+		} catch (ArrayIndexOutOfBoundsException e) {
+			throw new AssertionFailedError("incorrect re-serialization of tAttrChoose");
+		}
+		assertTrue(Arrays.equals(data, data2));
+	}
+}



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