diff options
author | Josh Micich <josh@apache.org> | 2008-12-16 05:44:32 +0000 |
---|---|---|
committer | Josh Micich <josh@apache.org> | 2008-12-16 05:44:32 +0000 |
commit | fdc5f9a25cb7a1c3800d16d653fe395cab1b65cb (patch) | |
tree | 7efd643f4b392532d614796a9e20a21ee442bb75 /src/testcases | |
parent | f50adf36d183f2d29cf4110bcb539a9e3dc5dce1 (diff) | |
download | poi-fdc5f9a25cb7a1c3800d16d653fe395cab1b65cb.tar.gz poi-fdc5f9a25cb7a1c3800d16d653fe395cab1b65cb.zip |
Fix for bug 46385 (by patch 46362 from Matsuyama Tomohiro) fixed serialization of StyleRecord with unicode name
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@726969 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases')
-rw-r--r-- | src/testcases/org/apache/poi/hssf/record/TestStyleRecord.java | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/testcases/org/apache/poi/hssf/record/TestStyleRecord.java b/src/testcases/org/apache/poi/hssf/record/TestStyleRecord.java index bfe11dd3a8..cce5dab0a8 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestStyleRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestStyleRecord.java @@ -17,17 +17,30 @@ package org.apache.poi.hssf.record;
+import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
+
+import org.apache.poi.util.HexRead;
+
/**
- *
+ * Tests for {@link StyleRecord}
*/
public final class TestStyleRecord extends TestCase {
- public void testUnicodeReadName() {
- byte[] data = {
- 17, 0, 9, 0, 1, 56, 94, -60, -119, 95, 0, 83, 0, 104, 0, 101, 0, 101, 0, 116, 0, 49, 0, 92, 40, //92, 36
- };
- RecordInputStream in = TestcaseRecordInputStream.create(StyleRecord.sid, data);
- StyleRecord sr = new StyleRecord(in);
- assertEquals("\u5E38\u89C4_Sheet1", sr.getName()); // "<Conventional>_Sheet1"
- }
+ public void testUnicodeReadName() {
+ byte[] data = HexRead.readFromString(
+ "11 00 09 00 01 38 5E C4 89 5F 00 53 00 68 00 65 00 65 00 74 00 31 00");
+ RecordInputStream in = TestcaseRecordInputStream.create(StyleRecord.sid, data);
+ StyleRecord sr = new StyleRecord(in);
+ assertEquals("\u5E38\u89C4_Sheet1", sr.getName()); // "<Conventional>_Sheet1"
+ byte[] ser;
+ try {
+ ser = sr.serialize();
+ } catch (IllegalStateException e) {
+ if (e.getMessage().equals("Incorrect number of bytes written - expected 27 but got 18")) {
+ throw new AssertionFailedError("Identified bug 46385");
+ }
+ throw e;
+ }
+ TestcaseRecordInputStream.confirmRecordEncoding(StyleRecord.sid, data, ser);
+ }
}
|