aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache
diff options
context:
space:
mode:
authorYegor Kozlov <yegor@apache.org>2009-01-29 16:03:52 +0000
committerYegor Kozlov <yegor@apache.org>2009-01-29 16:03:52 +0000
commitd01cd80981cc07a6b7e13430a49faac3bd76be54 (patch)
treef2f6777921add81abe846fcc35d638c5ecc30354 /src/testcases/org/apache
parentfce473fada9fbf45563b76514d7bc7b204decbb0 (diff)
downloadpoi-d01cd80981cc07a6b7e13430a49faac3bd76be54.tar.gz
poi-d01cd80981cc07a6b7e13430a49faac3bd76be54.zip
fixed bugs 40520 and 46553: HSSFFont.applyFont() formats wrong parts of HSSFRichTextString
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@738908 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache')
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRichTextString.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRichTextString.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRichTextString.java
index 016128a200..a14c2510b5 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRichTextString.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRichTextString.java
@@ -74,4 +74,59 @@ public class TestHSSFRichTextString extends TestCase
r.clearFormatting();
assertEquals(0, r.numFormattingRuns());
}
+
+
+ /**
+ * Test case proposed in Bug 40520: formated twice => will format whole String
+ */
+ public void test40520_1(){
+
+ short font = 3;
+
+ HSSFRichTextString r = new HSSFRichTextString("f0_123456789012345678901234567890123456789012345678901234567890");
+
+ r.applyFont(0,7,font);
+ r.applyFont(5,9,font);
+
+ for(int i=0; i < 7; i++) assertEquals(font, r.getFontAtIndex(i));
+ for(int i=5; i < 9; i++) assertEquals(font, r.getFontAtIndex(i));
+ for(int i=9; i < r.length(); i++) assertEquals(HSSFRichTextString.NO_FONT, r.getFontAtIndex(i));
+ }
+
+ /**
+ * Test case proposed in Bug 40520: overlapped range => will format whole String
+ */
+ public void test40520_2(){
+
+ short font = 3;
+ HSSFRichTextString r = new HSSFRichTextString("f0_123456789012345678901234567890123456789012345678901234567890");
+
+ r.applyFont(0,2,font);
+ for(int i=0; i < 2; i++) assertEquals(font, r.getFontAtIndex(i));
+ for(int i=2; i < r.length(); i++) assertEquals(HSSFRichTextString.NO_FONT, r.getFontAtIndex(i));
+
+ r.applyFont(0,2,font);
+ for(int i=0; i < 2; i++) assertEquals(font, r.getFontAtIndex(i));
+ for(int i=2; i < r.length(); i++) assertEquals(HSSFRichTextString.NO_FONT, r.getFontAtIndex(i));
+ }
+
+ /**
+ * Test case proposed in Bug 40520: formated twice => will format whole String
+ */
+ public void test40520_3(){
+
+ short font = 3;
+ HSSFRichTextString r = new HSSFRichTextString("f0_123456789012345678901234567890123456789012345678901234567890");
+
+ // wrong order => will format 0-6
+ r.applyFont(0,2,font);
+ r.applyFont(5,7,font);
+ r.applyFont(0,2,font);
+
+ r.applyFont(0,2,font);
+ for(int i=0; i < 2; i++) assertEquals(font, r.getFontAtIndex(i));
+ for(int i=2; i < 5; i++) assertEquals(HSSFRichTextString.NO_FONT, r.getFontAtIndex(i));
+ for(int i=5; i < 7; i++) assertEquals(font, r.getFontAtIndex(i));
+ for(int i=7; i < r.length(); i++) assertEquals(HSSFRichTextString.NO_FONT, r.getFontAtIndex(i));
+ }
}