Add test for bug 58805

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1923055 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2025-01-11 09:23:50 +00:00
parent 38e7fe63a8
commit 534d24dc74
2 changed files with 19 additions and 0 deletions

View File

@ -27,6 +27,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
@ -784,4 +786,21 @@ class TestBugs {
assertNotNull(pictures);
}
}
//
@Test
void test58805() throws IOException {
try (HWPFDocument doc = openSampleFile("header_footer_replace.doc")) {
Range oRange = doc.getHeaderStoryRange();
for (int i = 0; i < oRange.numCharacterRuns(); i++) {
CharacterRun run = oRange.getCharacterRun(i);
run.replaceText("_TEST_", "This text is longer than the initial text. It goes on and on without interruption.");
}
try (FileOutputStream fos = new FileOutputStream(new File("/tmp/test.doc"))) {
doc.write(fos);
}
}
}
}

Binary file not shown.