You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by se...@apache.org on 2011/07/25 13:02:04 UTC
svn commit: r1150628 - in /poi/trunk/src/scratchpad:
src/org/apache/poi/hwpf/model/PAPBinTable.java
testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java
Author: sergey
Date: Mon Jul 25 11:02:03 2011
New Revision: 1150628
URL: http://svn.apache.org/viewvc?rev=1150628&view=rev
Log:
update assertion in PAPBinTable
Modified:
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java?rev=1150628&r1=1150627&r2=1150628&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java Mon Jul 25 11:02:03 2011
@@ -249,7 +249,9 @@ public class PAPBinTable
{
PAPX papx = oldPapxSortedByEndPos.get( papxIndex );
- assert papx.getEnd() > startInclusive;
+ assert papxIndex + 1 == oldPapxSortedByEndPos.size()
+ || papx.getEnd() > startInclusive;
+
if ( papx.getEnd() - 1 > charIndex )
{
lastPapxIndex = papxIndex;
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java?rev=1150628&r1=1150627&r2=1150628&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java Mon Jul 25 11:02:03 2011
@@ -18,77 +18,67 @@
package org.apache.poi.hwpf.model;
import java.io.ByteArrayOutputStream;
-import java.util.ArrayList;
+import java.util.List;
import junit.framework.TestCase;
import org.apache.poi.hwpf.HWPFDocFixture;
+import org.apache.poi.hwpf.HWPFTestDataSamples;
import org.apache.poi.hwpf.model.io.HWPFFileSystem;
-public final class TestPAPBinTable
- extends TestCase
+public final class TestPAPBinTable extends TestCase
{
- private PAPBinTable _pAPBinTable = null;
- private HWPFDocFixture _hWPFDocFixture;
- private TextPieceTable fakeTPT = new TextPieceTable();
-
- public void testReadWrite()
- throws Exception
- {
- FileInformationBlock fib = _hWPFDocFixture._fib;
- byte[] mainStream = _hWPFDocFixture._mainStream;
- byte[] tableStream = _hWPFDocFixture._tableStream;
-
- _pAPBinTable = new PAPBinTable(mainStream, tableStream, null, fib.getFcPlcfbtePapx(), fib.getLcbPlcfbtePapx(), null, fakeTPT, false);
-
- HWPFFileSystem fileSys = new HWPFFileSystem();
+ public void testObIs()
+ {
+ // shall not fail with assertions on
+ HWPFTestDataSamples.openSampleFile( "ob_is.doc" );
+ }
- _pAPBinTable.writeTo(fileSys, 0);
- ByteArrayOutputStream tableOut = fileSys.getStream("1Table");
- ByteArrayOutputStream mainOut = fileSys.getStream("WordDocument");
+ public void testReadWrite() throws Exception
+ {
+ /** @todo verify the constructors */
+ HWPFDocFixture _hWPFDocFixture = new HWPFDocFixture( this,
+ HWPFDocFixture.DEFAULT_TEST_FILE );
- byte[] newTableStream = tableOut.toByteArray();
- byte[] newMainStream = mainOut.toByteArray();
+ _hWPFDocFixture.setUp();
+ TextPieceTable fakeTPT = new TextPieceTable();
- PAPBinTable newBinTable = new PAPBinTable(newMainStream, newTableStream, null,0, newTableStream.length, null, fakeTPT, false);
+ FileInformationBlock fib = _hWPFDocFixture._fib;
+ byte[] mainStream = _hWPFDocFixture._mainStream;
+ byte[] tableStream = _hWPFDocFixture._tableStream;
- ArrayList oldTextRuns = _pAPBinTable.getParagraphs();
- ArrayList newTextRuns = newBinTable.getParagraphs();
+ PAPBinTable _pAPBinTable = new PAPBinTable( mainStream, tableStream,
+ null, fib.getFcPlcfbtePapx(), fib.getLcbPlcfbtePapx(), null,
+ fakeTPT, false );
- assertEquals(oldTextRuns.size(), newTextRuns.size());
+ HWPFFileSystem fileSys = new HWPFFileSystem();
- int size = oldTextRuns.size();
- for (int x = 0; x < size; x++)
- {
- PropertyNode oldNode = (PropertyNode)oldTextRuns.get(x);
- PropertyNode newNode = (PropertyNode)newTextRuns.get(x);
+ _pAPBinTable.writeTo( fileSys, 0 );
+ ByteArrayOutputStream tableOut = fileSys.getStream( "1Table" );
+ ByteArrayOutputStream mainOut = fileSys.getStream( "WordDocument" );
- assertTrue(oldNode.equals(newNode));
- }
+ byte[] newTableStream = tableOut.toByteArray();
+ byte[] newMainStream = mainOut.toByteArray();
+ PAPBinTable newBinTable = new PAPBinTable( newMainStream,
+ newTableStream, null, 0, newTableStream.length, null, fakeTPT,
+ false );
+ List<PAPX> oldTextRuns = _pAPBinTable.getParagraphs();
+ List<PAPX> newTextRuns = newBinTable.getParagraphs();
+ assertEquals( oldTextRuns.size(), newTextRuns.size() );
- }
+ int size = oldTextRuns.size();
+ for ( int x = 0; x < size; x++ )
+ {
+ PAPX oldNode = oldTextRuns.get( x );
+ PAPX newNode = newTextRuns.get( x );
- protected void setUp()
- throws Exception
- {
- super.setUp();
- /**@todo verify the constructors*/
- _hWPFDocFixture = new HWPFDocFixture(this, HWPFDocFixture.DEFAULT_TEST_FILE);
-
- _hWPFDocFixture.setUp();
- }
-
- protected void tearDown()
- throws Exception
- {
- _hWPFDocFixture.tearDown();
-
- _hWPFDocFixture = null;
- super.tearDown();
- }
+ assertTrue( oldNode.equals( newNode ) );
+ }
+ _hWPFDocFixture.tearDown();
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org