Esempio n. 1
0
void BufferFactoryTest::testCreateByteBuffer3() {

    std::vector<unsigned char> array;
    array.resize( 500 );
    ByteBuffer* buffer = BufferFactory::createByteBuffer( &array[0], 500, 100, 400 );
    CPPUNIT_ASSERT( buffer != NULL );
    CPPUNIT_ASSERT( buffer->hasArray() == true );
    CPPUNIT_ASSERT( buffer->array() == &array[0] );
    CPPUNIT_ASSERT( buffer->capacity() == 400 );
    CPPUNIT_ASSERT( buffer->isReadOnly() == false );

    delete buffer;
}
void ByteArrayBufferTest::testReadOnlyArray() {

    ByteBuffer* readOnly = testBuffer1->asReadOnlyBuffer();

    CPPUNIT_ASSERT( readOnly != NULL );
    CPPUNIT_ASSERT( readOnly->isReadOnly() == true );

    CPPUNIT_ASSERT_THROW_MESSAGE(
        "Should throw UnsupportedOperationException",
        readOnly->array(),
        UnsupportedOperationException );

    CPPUNIT_ASSERT_THROW_MESSAGE(
        "Should throw UnsupportedOperationException",
        readOnly->arrayOffset(),
        UnsupportedOperationException );

    delete readOnly;
}