Extend AbstractByteArrayModelIfTest::testFill to test filling past end

parent 9770e7e0
......@@ -38,6 +38,11 @@ Q_DECLARE_METATYPE(Okteta::ArrayChangeMetricsList)
namespace Okteta
{
bool AbstractByteArrayModelIfTest::byteArrayModelSizeCanBeChanged() const
{
return true;
}
// ---------------------------------------------------------------- Tests -----
......@@ -215,6 +220,22 @@ void AbstractByteArrayModelIfTest::testFill()
QVERIFY( mByteArrayModel->isModified() );
checkContentsReplaced( fillRange, fillRange.width() );
// fill() at end with length reaching behind end
static const Size behindEndSize = 2;
mByteArrayModel->setModified( false );
mByteArrayModel->fill( BlankChar );
fillRange.moveToEnd( size - 1 + behindEndSize );
clearSignalSpys();
mByteArrayModel->fill( PaintChar, fillRange.start(), fillRange.width() );
const AddressRange removedRange( fillRange.start(), size-1 );
const AddressRange insertedRange = byteArrayModelSizeCanBeChanged() ? fillRange : removedRange;
QCOMPARE( mByteArrayModel->byte(insertedRange.nextBeforeStart()), BlankChar );
QCOMPARE( copy.compare(*mByteArrayModel, insertedRange, insertedRange.start()-behindEndSize), 0 );
QVERIFY( mByteArrayModel->isModified() );
QCOMPARE( mByteArrayModel->size(), insertedRange.nextBehindEnd() );
checkContentsReplaced( removedRange, insertedRange.width() );
// fill() at mid
mByteArrayModel->setModified( false );
mByteArrayModel->fill( BlankChar );
......
......@@ -46,6 +46,7 @@ class AbstractByteArrayModelIfTest : public QObject
protected: // our API
virtual AbstractByteArrayModel* createByteArrayModel() = 0;
virtual void deleteByteArrayModel( AbstractByteArrayModel* byteArrayModel ) = 0;
virtual bool byteArrayModelSizeCanBeChanged() const;
protected:
void checkContentsReplaced( Address Position, Size removedLength, int insertedLength );
......
......@@ -34,6 +34,11 @@ namespace Okteta
static const Size FixedSizeByteArrayModelSize = 60;
bool FixedSizeByteArrayModelAbstractByteArrayModelIfTest::byteArrayModelSizeCanBeChanged() const
{
return false;
}
AbstractByteArrayModel* FixedSizeByteArrayModelAbstractByteArrayModelIfTest::createByteArrayModel()
{
return new FixedSizeByteArrayModel( FixedSizeByteArrayModelSize );
......
......@@ -36,6 +36,7 @@ class FixedSizeByteArrayModelAbstractByteArrayModelIfTest : public AbstractByteA
protected: // AbstractByteArrayModelIfTest API
AbstractByteArrayModel* createByteArrayModel();
void deleteByteArrayModel( AbstractByteArrayModel* byteArrayModel );
bool byteArrayModelSizeCanBeChanged() const;
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment