From: Josh Micich Date: Wed, 5 Nov 2008 23:35:02 +0000 (+0000) Subject: Refactoring test case X-Git-Tag: trunk_20081106~4 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=81c543b441f17e023bdd19a5382234c911a342e9;p=poi.git Refactoring test case git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@711741 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/testcases/org/apache/poi/hssf/record/TestUnicodeString.java b/src/testcases/org/apache/poi/hssf/record/TestUnicodeString.java index a97462f762..d3b3155bc1 100755 --- a/src/testcases/org/apache/poi/hssf/record/TestUnicodeString.java +++ b/src/testcases/org/apache/poi/hssf/record/TestUnicodeString.java @@ -25,6 +25,7 @@ import junit.framework.TestCase; * @author Jason Height (jheight at apache.org) */ public final class TestUnicodeString extends TestCase { + private static final int MAX_DATA_SIZE = SSTRecord.MAX_RECORD_SIZE; /** a 4 character string requiring 16 bit encoding */ private static final String STR_16_BIT = "A\u591A\u8A00\u8A9E"; @@ -34,7 +35,7 @@ public final class TestUnicodeString extends TestCase { } private static void confirmSize(int expectedSize, UnicodeString s, int amountUsedInCurrentRecord) { UnicodeString.UnicodeRecordStats stats = new UnicodeString.UnicodeRecordStats(); - stats.remainingSize = SSTRecord.MAX_RECORD_SIZE-amountUsedInCurrentRecord; + stats.remainingSize = MAX_DATA_SIZE-amountUsedInCurrentRecord; s.getRecordSize(stats); assertEquals(expectedSize, stats.recordSize); } @@ -77,45 +78,45 @@ public final class TestUnicodeString extends TestCase { public void testPerfectStringSize() { //Test a basic string - UnicodeString s = makeUnicodeString(SSTRecord.MAX_RECORD_SIZE-2-1); - confirmSize(SSTRecord.MAX_RECORD_SIZE, s); + UnicodeString s = makeUnicodeString(MAX_DATA_SIZE-2-1); + confirmSize(MAX_DATA_SIZE, s); //Test an uncompressed string //Note that we can only ever get to a maximim size of 8227 since an uncompressed //string is writing double bytes. - s = makeUnicodeString((SSTRecord.MAX_RECORD_SIZE-2-1)/2, true); + s = makeUnicodeString((MAX_DATA_SIZE-2-1)/2, true); s.setOptionFlags((byte)0x1); - confirmSize(SSTRecord.MAX_RECORD_SIZE-1, s); + confirmSize(MAX_DATA_SIZE-1, s); } public void testPerfectRichStringSize() { //Test a rich text string - UnicodeString s = makeUnicodeString(SSTRecord.MAX_RECORD_SIZE-2-1-8-2); + UnicodeString s = makeUnicodeString(MAX_DATA_SIZE-2-1-8-2); s.addFormatRun(new UnicodeString.FormatRun((short)1,(short)0)); s.addFormatRun(new UnicodeString.FormatRun((short)2,(short)1)); s.setOptionFlags((byte)0x8); - confirmSize(SSTRecord.MAX_RECORD_SIZE, s); + confirmSize(MAX_DATA_SIZE, s); //Test an uncompressed rich text string //Note that we can only ever get to a maximum size of 8227 since an uncompressed //string is writing double bytes. - s = makeUnicodeString((SSTRecord.MAX_RECORD_SIZE-2-1-8-2)/2, true); + s = makeUnicodeString((MAX_DATA_SIZE-2-1-8-2)/2, true); s.addFormatRun(new UnicodeString.FormatRun((short)1,(short)0)); s.addFormatRun(new UnicodeString.FormatRun((short)2,(short)1)); s.setOptionFlags((byte)0x9); - confirmSize(SSTRecord.MAX_RECORD_SIZE-1, s); + confirmSize(MAX_DATA_SIZE-1, s); } public void testContinuedStringSize() { //Test a basic string - UnicodeString s = makeUnicodeString(SSTRecord.MAX_RECORD_SIZE-2-1+20); - confirmSize(SSTRecord.MAX_RECORD_SIZE+4+1+20, s); + UnicodeString s = makeUnicodeString(MAX_DATA_SIZE-2-1+20); + confirmSize(MAX_DATA_SIZE+4+1+20, s); } /** Tests that a string size calculation that fits neatly in two records, the second being a continue*/ public void testPerfectContinuedStringSize() { //Test a basic string - int strSize = SSTRecord.MAX_RECORD_SIZE*2; + int strSize = MAX_DATA_SIZE*2; //String overhead strSize -= 3; //Continue Record overhead @@ -123,7 +124,7 @@ public final class TestUnicodeString extends TestCase { //Continue Record additional byte overhead strSize -= 1; UnicodeString s = makeUnicodeString(strSize); - confirmSize(SSTRecord.MAX_RECORD_SIZE*2, s); + confirmSize(MAX_DATA_SIZE*2, s); }