From b05947a1814a1013169d2b5b4d92caa95a3eec86 Mon Sep 17 00:00:00 2001 From: Glen Stampoultzis Date: Wed, 12 Jun 2002 09:07:51 +0000 Subject: [PATCH] A testcase that I should have added before. git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352683 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/hssf/data/extendedtextstrings.txt | 55 +++++++++++++++++++ .../poi/hssf/record/TestSSTDeserializer.java | 35 +++++++++++- 2 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 src/testcases/org/apache/poi/hssf/data/extendedtextstrings.txt diff --git a/src/testcases/org/apache/poi/hssf/data/extendedtextstrings.txt b/src/testcases/org/apache/poi/hssf/data/extendedtextstrings.txt new file mode 100644 index 000000000..93c080bb9 --- /dev/null +++ b/src/testcases/org/apache/poi/hssf/data/extendedtextstrings.txt @@ -0,0 +1,55 @@ +###################################################### +# Rich text with extended information test + +[rich-header] +1D 00 # String length 0x1b=29 +0D # Option flag, rich text + 16bit + extended +02 00 # Formatting runs +03 00 00 00 # Far east data size +# String: At a dinner party or +41 00 74 00 20 00 61 00 20 00 +64 00 69 00 6E 00 6E 00 65 00 +72 00 20 00 70 00 61 00 72 00 +74 00 79 00 20 00 6F 00 72 00 + +[rich-continue1] +# Continuation record +00 # option flag + +# string:at at at +41 74 20 +41 74 20 +41 74 20 + +00 00 # Formatting run 1, first formated char at 0 +00 00 # Formatting run 1, Index to font record +02 00 # Formatting run 2, first formated char at 2 +00 00 # Formatting run 2, Index to font record + +FF FF FF # extended data + + +######################################################## +# Normal text with extended information. + +[norich-header] +1D 00 # String length 0x1b=29 +05 # Option flag, 16bit + extended +03 00 00 00 # Far east data size +# String: At a dinner party or +41 00 74 00 20 00 61 00 20 00 +64 00 69 00 6E 00 6E 00 65 00 +72 00 20 00 70 00 61 00 72 00 +74 00 79 00 20 00 6F 00 72 00 + +[norich-continue1] +# Continuation record +00 # option flag + +# string:at at at +41 74 20 +41 74 20 +41 74 20 + +FF FF FF # extended data + diff --git a/src/testcases/org/apache/poi/hssf/record/TestSSTDeserializer.java b/src/testcases/org/apache/poi/hssf/record/TestSSTDeserializer.java index b63a59795..3f6dbd75e 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestSSTDeserializer.java +++ b/src/testcases/org/apache/poi/hssf/record/TestSSTDeserializer.java @@ -72,6 +72,11 @@ public class TestSSTDeserializer private String _test_file_path; private static final String _test_file_path_property = "HSSF.testdata.path"; + public TestSSTDeserializer( String s ) + { + super( s ); + } + protected void setUp() throws Exception { _test_file_path = System.getProperty( _test_file_path_property ); @@ -83,7 +88,7 @@ public class TestSSTDeserializer byte[] bytes = HexRead.readData( _test_file_path + File.separator + "richtextdata.txt", "header" ); BinaryTree strings = new BinaryTree(); SSTDeserializer deserializer = new SSTDeserializer( strings ); - deserializer.manufactureStrings( bytes, 0, (short) 45 ); + deserializer.manufactureStrings( bytes, 0, (short)bytes.length ); byte[] continueBytes = HexRead.readData( _test_file_path + File.separator + "richtextdata.txt", "continue1" ); deserializer.processContinueRecord( continueBytes ); @@ -96,7 +101,7 @@ public class TestSSTDeserializer byte[] bytes = HexRead.readData( _test_file_path + File.separator + "evencontinuation.txt", "header" ); BinaryTree strings = new BinaryTree(); SSTDeserializer deserializer = new SSTDeserializer( strings ); - deserializer.manufactureStrings( bytes, 0, (short) 43 ); + deserializer.manufactureStrings( bytes, 0, (short)bytes.length ); byte[] continueBytes = HexRead.readData( _test_file_path + File.separator + "evencontinuation.txt", "continue1" ); deserializer.processContinueRecord( continueBytes ); @@ -114,7 +119,7 @@ public class TestSSTDeserializer byte[] bytes = HexRead.readData( _test_file_path + File.separator + "stringacross2continuations.txt", "header" ); BinaryTree strings = new BinaryTree(); SSTDeserializer deserializer = new SSTDeserializer( strings ); - deserializer.manufactureStrings( bytes, 0, (short) 43 ); + deserializer.manufactureStrings( bytes, 0, (short)bytes.length ); bytes = HexRead.readData( _test_file_path + File.separator + "stringacross2continuations.txt", "continue1" ); deserializer.processContinueRecord( bytes ); bytes = HexRead.readData( _test_file_path + File.separator + "stringacross2continuations.txt", "continue2" ); @@ -125,4 +130,28 @@ public class TestSSTDeserializer } + public void testExtendedStrings() + throws Exception + { + byte[] bytes = HexRead.readData( _test_file_path + File.separator + "extendedtextstrings.txt", "rich-header" ); + BinaryTree strings = new BinaryTree(); + SSTDeserializer deserializer = new SSTDeserializer( strings ); + deserializer.manufactureStrings( bytes, 0, (short)bytes.length ); + byte[] continueBytes = HexRead.readData( _test_file_path + File.separator + "extendedtextstrings.txt", "rich-continue1" ); + deserializer.processContinueRecord( continueBytes ); + + assertEquals( "At a dinner party orAt At At ", strings.get( new Integer( 0 ) ) + "" ); + + + bytes = HexRead.readData( _test_file_path + File.separator + "extendedtextstrings.txt", "norich-header" ); + strings = new BinaryTree(); + deserializer = new SSTDeserializer( strings ); + deserializer.manufactureStrings( bytes, 0, (short)bytes.length ); + continueBytes = HexRead.readData( _test_file_path + File.separator + "extendedtextstrings.txt", "norich-continue1" ); + deserializer.processContinueRecord( continueBytes ); + + assertEquals( "At a dinner party orAt At At ", strings.get( new Integer( 0 ) ) + "" ); + + } + }