From fbdf4dca6827fbb2ee60452048aa13c852927a41 Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Fri, 6 Oct 2017 17:41:20 +0000 Subject: [PATCH] Bug 61586: Add test which shows that it works as expected git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1811355 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/hwpf/usermodel/TestRangeSymbols.java | 96 ++++++++++++++++-- test-data/document/61586.doc | Bin 0 -> 27648 bytes 2 files changed, 89 insertions(+), 7 deletions(-) create mode 100644 test-data/document/61586.doc 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 449bdffc29..49902b77cd 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 0000000000000000000000000000000000000000..cc044515a34b946a4bb3dde5bf9930a5e25df8d7 GIT binary patch literal 27648 zcmeHQ3pmuv`=4F66(S+Gvh5)%Es{tnmq>_6x|fY*-G!u5bibS~bXBRSR7W?Zy9%j9 zDJi<4bib&!A}QMc`|kQm%Bgey=l_3x=lShC&*%HjyfgE@Gw+Pqnc4Tdim!IKpL$TU zinIy?i3Ir~kR{SB_%w){P-!JXOd*cEF9Lx8*~S2fio?Ii0@Z1`q&tz7B!sV=je|%C zj4T8OAr64{WOCr-z>rTNpM>0R9NTJ&R6L+fhzF$aK>enspqS=B*@4pAoY54a_-#>?+cHq{C`$F4Dud~} zkaz?2gk7fUx1y+z4dq(PX`M#6BCmZ z1AjKpD8z+nU^CLLJChUY%QP`#8u$xYb|IXY?rbKLDnBHG%MD_NOf^t2P=L`FhkvOB zV2?)w&;il_82|$y3y=pW0NMkT0jdBN;5PspU;^k3=nF6hSOEF~Yyh?ZJHTLoJ)q%Z z&GQF$O7c(S@87n1TmJ7g@zbXSjCCJsL)xqHI%~WjA&#<=kpN7~gVg492Q^+szstn2 z2aRHNmJOtl5WXtUDj=4q37;);p+54d!YB{xH>c%Qc{8{NpdNCGD$05QvcB>_7S!R` z*?z6lq*1IXH-lQ(cLb_Ia1<}BLJ~jS0<~W`>hB$UOZg>W0Y&o^R zNqlTG=Y5+w-w607(Xxs-{*PJ!K8yW*g%e&F!|5YDx-+OT{$?cqQPpB$|49~rwWHqD}0a)P(XlKz}3?<$eu=i4F6eAe9Uz@=ZPjO5h_km~e?7 z$e#)tq6m`=hj;|QU-%3sJm5J%D?%X`g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