/**
* test simple addString
*/
public void testSimpleAddString() {
SSTRecord record = new SSTRecord();
UnicodeString s1 = new UnicodeString("Hello world");
// \u2122 is the encoding of the trademark symbol ...
UnicodeString s2 = new UnicodeString("Hello world\u2122");
assertEquals( 0, record.addString( s1 ) );
assertEquals( s1, record.getString( 0 ) );
assertEquals( 1, record.countStrings() );
assertEquals( 1, record.getNumStrings() );
assertEquals( 1, record.getNumUniqueStrings() );
assertEquals( 0, record.addString( s1 ) );
assertEquals( s1, record.getString( 0 ) );
assertEquals( 1, record.countStrings() );
assertEquals( 2, record.getNumStrings() );
assertEquals( 1, record.getNumUniqueStrings() );
assertEquals( 1, record.addString( s2 ) );
assertEquals( s2, record.getString( 1 ) );
assertEquals( 2, record.countStrings() );
assertEquals( 3, record.getNumStrings() );
assertEquals( 2, record.getNumUniqueStrings() );
Iterator iter = record.getStrings();
while ( iter.hasNext() )
{
UnicodeString ucs = (UnicodeString) iter.next();
if ( ucs.equals( s1 ) )
{
assertEquals( (byte) 0, ucs.getOptionFlags() );
}
else if ( ucs.equals( s2 ) )
{
assertEquals( (byte) 1, ucs.getOptionFlags() );
}
else
{
fail( "cannot match string: " + ucs.getString() );
}
}
}