diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeSymbols.java b/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeSymbols.java index 449bdffc2..49902b77c 100644 --- a/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeSymbols.java +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeSymbols.java @@ -19,16 +19,18 @@ package org.apache.poi.hwpf.usermodel; import java.io.IOException; -import junit.framework.TestCase; - import org.apache.poi.hwpf.HWPFDocument; import org.apache.poi.hwpf.HWPFTestDataSamples; +import org.apache.poi.hwpf.model.Ffn; +import org.junit.Test; + +import static org.junit.Assert.*; /** * API for processing of symbols, see Bugzilla 49908 */ -public final class TestRangeSymbols extends TestCase { - +public final class TestRangeSymbols { + @Test public void test() throws IOException { HWPFDocument doc = HWPFTestDataSamples.openSampleFile("Bug49908.doc"); @@ -36,13 +38,93 @@ public final class TestRangeSymbols extends TestCase { assertTrue(range.numCharacterRuns() >= 2); CharacterRun chr = range.getCharacterRun(0); - assertEquals(false, chr.isSymbol()); + assertFalse(chr.isSymbol()); chr = range.getCharacterRun(1); - assertEquals(true, chr.isSymbol()); + assertTrue(chr.isSymbol()); assertEquals("\u0028", chr.text()); - assertEquals("Wingdings", chr.getSymbolFont().getMainFontName()); + Ffn symbolFont = chr.getSymbolFont(); + assertNotNull(symbolFont); + assertEquals("Wingdings", symbolFont.getMainFontName()); assertEquals(0xf028, chr.getSymbolCharacter()); } + @Test + public void test61586() throws IOException { + HWPFDocument document = HWPFTestDataSamples.openSampleFile("61586.doc"); + assertEquals("\r" + + "\r" + + "TEST( \r" + + "111 (g.h/mL (AUC) and 15 (g/mL (Cmax). \r" + + "TEST( \r" + + "Greek mu(\r" + + "(\r\r", document.getText().toString()); + + Range range = document.getRange(); + + assertEquals(26, range.numCharacterRuns()); + + // newline + CharacterRun chr = range.getCharacterRun(0); + assertFalse(chr.isSymbol()); + assertEquals("\r", chr.text()); + + // "TEST" + chr = range.getCharacterRun(2); + assertFalse(chr.isSymbol()); + assertEquals("TEST", chr.text()); + + // "registered" symbol + chr = range.getCharacterRun(3); + assertTrue(chr.isSymbol()); + assertEquals("\u0028", chr.text()); + Ffn symbolFont = chr.getSymbolFont(); + assertNotNull(symbolFont); + assertEquals("Symbol", symbolFont.getMainFontName()); + assertEquals(0xf0e2, chr.getSymbolCharacter()); + assertEquals("(", chr.text()); + + // Greek "mu" symbol + chr = range.getCharacterRun(8); + assertTrue(chr.isSymbol()); + assertEquals("\u0028", chr.text()); + symbolFont = chr.getSymbolFont(); + assertNotNull(symbolFont); + assertEquals("Symbol", symbolFont.getMainFontName()); + assertEquals(0xf06d, chr.getSymbolCharacter()); + + // Greek "mu" symbol + chr = range.getCharacterRun(12); + assertTrue(chr.isSymbol()); + assertEquals("\u0028", chr.text()); + symbolFont = chr.getSymbolFont(); + assertNotNull(symbolFont); + assertEquals("Symbol", symbolFont.getMainFontName()); + assertEquals(0xf06d, chr.getSymbolCharacter()); + + // "registered" symbol + chr = range.getCharacterRun(17); + assertTrue(chr.isSymbol()); + assertEquals("\u0028", chr.text()); + symbolFont = chr.getSymbolFont(); + assertNotNull(symbolFont); + assertEquals("Symbol", symbolFont.getMainFontName()); + assertEquals(0xf0e2, chr.getSymbolCharacter()); + + // Greek "mu" symbol + chr = range.getCharacterRun(21); + assertTrue(chr.isSymbol()); + assertEquals("\u0028", chr.text()); + symbolFont = chr.getSymbolFont(); + assertNotNull(symbolFont); + assertEquals("Symbol", symbolFont.getMainFontName()); + assertEquals(0xf06d, chr.getSymbolCharacter()); + + // normal bracket, not a symbol + chr = range.getCharacterRun(23); + assertFalse(chr.isSymbol()); + assertEquals("\u0028", chr.text()); + + document.close(); + } } \ No newline at end of file diff --git a/test-data/document/61586.doc b/test-data/document/61586.doc new file mode 100644 index 000000000..cc044515a Binary files /dev/null and b/test-data/document/61586.doc differ