More testing... you can never have enough... :)

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352774 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Glen Stampoultzis 2002-07-15 13:22:50 +00:00
parent d17725d650
commit 7076f5c4d8

View File

@ -113,10 +113,32 @@ public class TestSSTRecordSizeCalculator
strings.put(new Integer(0), makeUnicodeString(perfectFit));
SSTRecordSizeCalculator calculator = new SSTRecordSizeCalculator(new SSTSerializer(recordLengths, strings, 1, 1));
assertEquals(SSTRecord.SST_RECORD_OVERHEAD
+ SSTRecord.MAX_DATA_SPACE,
+ COMPRESSED_PLAIN_STRING_OVERHEAD
+ perfectFit.length(),
calculator.getRecordSize());
}
/**
* Test the case where it's too big by one.
*/
public void testJustOversized()
throws Exception
{
String tooBig = new String(new char[SSTRecord.MAX_DATA_SPACE - COMPRESSED_PLAIN_STRING_OVERHEAD + 1]);
strings.put(new Integer(0), makeUnicodeString(tooBig));
SSTRecordSizeCalculator calculator = new SSTRecordSizeCalculator(new SSTSerializer(recordLengths, strings, 1, 1));
assertEquals(SSTRecord.SST_RECORD_OVERHEAD
+ COMPRESSED_PLAIN_STRING_OVERHEAD
+ tooBig.length() - 1
// continued
+ SSTRecord.STD_RECORD_OVERHEAD
+ OPTION_FIELD_SIZE
+ 1 // 1 char continued
,
calculator.getRecordSize());
}
public void testSecondStringStartsOnNewContinuation()
throws Exception
{
@ -133,6 +155,25 @@ public class TestSSTRecordSizeCalculator
calculator.getRecordSize());
}
public void testHeaderCrossesNormalContinuePoint()
throws Exception
{
String almostPerfectFit = new String(new char[SSTRecord.MAX_DATA_SPACE - COMPRESSED_PLAIN_STRING_OVERHEAD - 2]);
strings.put(new Integer(0), makeUnicodeString(almostPerfectFit));
String oneCharString = new String(new char[1]);
strings.put(new Integer(1), makeUnicodeString(oneCharString));
SSTRecordSizeCalculator calculator = new SSTRecordSizeCalculator(new SSTSerializer(recordLengths, strings, 1, 1));
assertEquals(SSTRecord.SST_RECORD_OVERHEAD
+ COMPRESSED_PLAIN_STRING_OVERHEAD
+ almostPerfectFit.length()
// second string
+ SSTRecord.STD_RECORD_OVERHEAD
+ COMPRESSED_PLAIN_STRING_OVERHEAD
+ oneCharString.length(),
calculator.getRecordSize());
}
public void setUp()
{