Exemplo n.º 1
0
bool 
DataBuffer::Test( )
{
    bool ok = true;
    cout << "Testing DataBuffer" << endl;

    DataBuffer buff;
    TESTCHECK( buff.Data() == 0, true, &ok );
    TESTCHECK( buff.Size(), 0, &ok );
    char sIn[ 10 ] = "123456789";
    Foo fIn = { 127, 2.5f };
    cout << "Add( char *, 10 )" << endl;
    buff.Add( sIn, 10 );
    TESTCHECK( *buff.Data(), '1', &ok );
    TESTCHECK( buff.Size(), 10, &ok );
    cout << "Add( Foo )" << endl;
    buff.Add( fIn );
    cout << "Read( 10 )" << endl;
    const char * sOut = buff.Read( 10 );
    TESTCHECK( (string( sIn ) == string( sOut )), true, &ok );
    cout << "Read< Foo >()" << endl;
    const Foo * pFoo = buff.Read< Foo >( );
    TESTCHECK( pFoo->i, 127, &ok );
    TESTCHECK( pFoo->f, 2.5f, &ok );
    
    if ( ok )
        cout << "DataBuffer PASSED." << endl << endl;
    else
        cout << "DataBuffer FAILED." << endl << endl;
    return ok;
}