/// Working method which should be overridden. virtualvoid SAL_CALL run() { for( int i = 0 ; i < m_iMax ; i ++ ) {
m_output->writeBytes( createIntSeq(i) );
}
m_output->closeOutput();
}
/** Called when run() is done. *Youmightwanttooverrideittodosomecleanup.
*/ virtualvoid SAL_CALL onTerminated()
{ deletethis;
}
private:
Reference < XOutputStream > m_output; int m_iMax;
};
class OPipeTest : public WeakImplHelper < XSimpleTest >
{ public: explicit OPipeTest( const Reference< XMultiServiceFactory > & rFactory );
~OPipeTest();
// available shouldn't return a negative value
input->skipBytes( seqWrite.getLength() - 5 );
ERROR_ASSERT( 0 == input->available() , "wrong available after skip" );
// 5 bytes should be available
output->writeBytes( seqWrite );
ERROR_ASSERT( 5 == input->available() , "wrong available after skip/write " );
ERROR_ASSERT( 10 == input->readSomeBytes( seqRead , 10 ) , "maximal number of bytes ignored" );
ERROR_ASSERT( seqWrite.getLength() -10 == input->readSomeBytes( seqRead , 100 ) , "something wrong with readSomeBytes" );
output->closeOutput(); try{
output->writeBytes( Sequence<sal_Int8> (100) );
ERROR_ASSERT( 0 , "writing on a closed stream does not cause an exception" );
} catch (IOException & )
{
}
ERROR_ASSERT(! input->readBytes( seqRead , 1 ), "eof not found !" );
input->closeInput(); try
{
input->readBytes( seqRead , 1 );
ERROR_ASSERT( 0 , "reading from a closed stream does not cause an exception" );
} catch( IOException & ) {
}
try
{
input->available( );
ERROR_ASSERT( 0 , "calling available from a closed stream should thrown an io exception" );
} catch( IOException & )
{
} try
{
input->skipBytes(42 );
ERROR_ASSERT( 0 , "calling available from a closed stream should thrown an io exception" );
} catch( IOException & )
{
}
}
void OPipeTest::testBufferResizing( const Reference < XInterface > &r )
{ int i; int iMax = 20000;
Reference< XInputStream > input( r , UNO_QUERY );
Reference < XOutputStream > output( r , UNO_QUERY );
ERROR_ASSERT( input.is() , "queryInterface on XInputStream failed" );
ERROR_ASSERT( output.is() , "queryInterface on XOutputStream failed" );
Sequence<sal_Int8> seqRead;
// this is just to better check the // internal buffers
output->writeBytes( Sequence<sal_Int8>(100) );
Sequence< sal_Int8 > dummy;
input->readBytes( dummy , 100);
for( i = 0 ; i < iMax ; i ++ ) {
output->writeBytes( createIntSeq( i ) );
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.