You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2010/10/22 18:41:02 UTC
svn commit: r1026399 - in /poi/trunk/src/scratchpad:
src/org/apache/poi/hwpf/model/CHPBinTable.java
testcases/org/apache/poi/hwpf/TestHWPFRangeParts.java
Author: nick
Date: Fri Oct 22 16:41:02 2010
New Revision: 1026399
URL: http://svn.apache.org/viewvc?rev=1026399&view=rev
Log:
Slightly expand tests, inspired by bug #50060, but ultimately show there is a deeper issue outstanding
Modified:
poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/TestHWPFRangeParts.java
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java?rev=1026399&r1=1026398&r2=1026399&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java Fri Oct 22 16:41:02 2010
@@ -199,7 +199,8 @@ public class CHPBinTable
int pageNum = docOffset/POIFSConstants.SMALLER_BIG_BLOCK_SIZE;
// get the ending fc
- int endingFc = ((PropertyNode)_textRuns.get(_textRuns.size() - 1)).getEnd();
+ PropertyNode lastRun = (PropertyNode)_textRuns.get(_textRuns.size() - 1);
+ int endingFc = lastRun.getEnd();
endingFc += fcMin;
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/TestHWPFRangeParts.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/TestHWPFRangeParts.java?rev=1026399&r1=1026398&r2=1026399&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/TestHWPFRangeParts.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/TestHWPFRangeParts.java Fri Oct 22 16:41:02 2010
@@ -98,108 +98,149 @@ public final class TestHWPFRangeParts ex
docAscii = HWPFTestDataSamples.openSampleFile("ThreeColHeadFoot.doc");
}
+ /**
+ * Note - this test runs several times, to ensure that things
+ * don't get broken as we write out and read back in again
+ * TODO - Make this work with 3+ runs
+ */
public void testBasics() {
- // First check the start and end bits
- assertEquals(
- 0,
- docAscii._cpSplit.getMainDocumentStart()
- );
- assertEquals(
- a_page_1.length() +
- 2 + // page break
- a_page_2.length(),
- docAscii._cpSplit.getMainDocumentEnd()
- );
-
- assertEquals(
- 238,
- docAscii._cpSplit.getFootnoteStart()
- );
- assertEquals(
- 238,
- docAscii._cpSplit.getFootnoteEnd()
- );
-
- assertEquals(
- 238,
- docAscii._cpSplit.getHeaderStoryStart()
- );
- assertEquals(
- 238 + headerDef.length() + a_header.length() +
- footerDef.length() + a_footer.length() + endHeaderFooter.length(),
- docAscii._cpSplit.getHeaderStoryEnd()
- );
+ HWPFDocument doc = docAscii;
+ for(int run=0; run<3; run++) {
+ // First check the start and end bits
+ assertEquals(
+ 0,
+ doc._cpSplit.getMainDocumentStart()
+ );
+ assertEquals(
+ a_page_1.length() +
+ 2 + // page break
+ a_page_2.length(),
+ doc._cpSplit.getMainDocumentEnd()
+ );
+
+ assertEquals(
+ 238,
+ doc._cpSplit.getFootnoteStart()
+ );
+ assertEquals(
+ 238,
+ doc._cpSplit.getFootnoteEnd()
+ );
+
+ assertEquals(
+ 238,
+ doc._cpSplit.getHeaderStoryStart()
+ );
+ assertEquals(
+ 238 + headerDef.length() + a_header.length() +
+ footerDef.length() + a_footer.length() + endHeaderFooter.length(),
+ doc._cpSplit.getHeaderStoryEnd()
+ );
+
+ // Write out and read back in again, ready for
+ // the next run of the test
+ // TODO run more than once
+ if(run < 1)
+ doc = HWPFTestDataSamples.writeOutAndReadBack(doc);
+ }
}
+ /**
+ * Note - this test runs several times, to ensure that things
+ * don't get broken as we write out and read back in again
+ * TODO - Make this work with 3+ runs
+ */
public void testContents() {
- Range r;
-
- // Now check the real ranges
- r = docAscii.getRange();
- assertEquals(
- a_page_1 +
- page_break + "\r" +
- a_page_2,
- r.text()
- );
-
- r = docAscii.getHeaderStoryRange();
- assertEquals(
- headerDef +
- a_header +
- footerDef +
- a_footer +
- endHeaderFooter,
- r.text()
- );
-
- r = docAscii.getOverallRange();
- assertEquals(
- a_page_1 +
- page_break + "\r" +
- a_page_2 +
- headerDef +
- a_header +
- footerDef +
- a_footer +
- endHeaderFooter +
- "\r",
- r.text()
- );
+ HWPFDocument doc = docAscii;
+ for(int run=0; run<3; run++) {
+ Range r;
+
+ // Now check the real ranges
+ r = doc.getRange();
+ assertEquals(
+ a_page_1 +
+ page_break + "\r" +
+ a_page_2,
+ r.text()
+ );
+
+ r = doc.getHeaderStoryRange();
+ assertEquals(
+ headerDef +
+ a_header +
+ footerDef +
+ a_footer +
+ endHeaderFooter,
+ r.text()
+ );
+
+ r = doc.getOverallRange();
+ assertEquals(
+ a_page_1 +
+ page_break + "\r" +
+ a_page_2 +
+ headerDef +
+ a_header +
+ footerDef +
+ a_footer +
+ endHeaderFooter +
+ "\r",
+ r.text()
+ );
+
+ // Write out and read back in again, ready for
+ // the next run of the test
+ // TODO run more than once
+ if(run < 1)
+ doc = HWPFTestDataSamples.writeOutAndReadBack(doc);
+ }
}
+ /**
+ * Note - this test runs several times, to ensure that things
+ * don't get broken as we write out and read back in again
+ */
public void testBasicsUnicode() {
- // First check the start and end bits
- assertEquals(
- 0,
- docUnicode._cpSplit.getMainDocumentStart()
- );
- assertEquals(
- u_page_1.length() +
- 2 + // page break
- u_page_2.length(),
- docUnicode._cpSplit.getMainDocumentEnd()
- );
-
- assertEquals(
- 408,
- docUnicode._cpSplit.getFootnoteStart()
- );
- assertEquals(
- 408,
- docUnicode._cpSplit.getFootnoteEnd()
- );
-
- assertEquals(
- 408,
- docUnicode._cpSplit.getHeaderStoryStart()
- );
- // TODO - fix this one
- assertEquals(
- 408 + headerDef.length() + u_header.length() +
- footerDef.length() + u_footer.length() + endHeaderFooter.length(),
- docUnicode._cpSplit.getHeaderStoryEnd()
- );
+ HWPFDocument doc = docUnicode;
+ for(int run=0; run<3; run++) {
+ // First check the start and end bits
+ assertEquals(
+ 0,
+ doc._cpSplit.getMainDocumentStart()
+ );
+ assertEquals(
+ u_page_1.length() +
+ 2 + // page break
+ u_page_2.length(),
+ doc._cpSplit.getMainDocumentEnd()
+ );
+
+ assertEquals(
+ 408,
+ doc._cpSplit.getFootnoteStart()
+ );
+ assertEquals(
+ 408,
+ doc._cpSplit.getFootnoteEnd()
+ );
+
+ assertEquals(
+ 408,
+ doc._cpSplit.getHeaderStoryStart()
+ );
+ // TODO - fix this one
+ assertEquals(
+ 408 + headerDef.length() + u_header.length() +
+ footerDef.length() + u_footer.length() + endHeaderFooter.length(),
+ doc._cpSplit.getHeaderStoryEnd()
+ );
+
+ // Write out and read back in again, ready for
+ // the next run of the test
+ // TODO run more than once
+ if(run < 1)
+ doc = HWPFTestDataSamples.writeOutAndReadBack(doc);
+ }
}
public void testContentsUnicode() {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org