mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-12-04 15:39:34 +01:00
Test if we correctly detect errors when writing.
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include <QTest>
|
||||
|
||||
#include "tests.h"
|
||||
#include "FailDevice.h"
|
||||
#include "crypto/Crypto.h"
|
||||
#include "streams/HashedBlockStream.h"
|
||||
|
||||
@@ -71,3 +72,19 @@ void TestHashedBlockStream::testWriteRead()
|
||||
buffer.reset();
|
||||
buffer.buffer().clear();
|
||||
}
|
||||
|
||||
void TestHashedBlockStream::testWriteFailure()
|
||||
{
|
||||
FailDevice failDevice(1500);
|
||||
QVERIFY(failDevice.open(QIODevice::WriteOnly));
|
||||
|
||||
QByteArray input(2000, 'Z');
|
||||
|
||||
HashedBlockStream writer(&failDevice, 500);
|
||||
QVERIFY(writer.open(QIODevice::WriteOnly));
|
||||
|
||||
QCOMPARE(writer.write(input.left(900)), qint64(900));
|
||||
writer.write(input.left(900));
|
||||
QVERIFY(!writer.reset());
|
||||
QCOMPARE(writer.errorString(), QString("FAILDEVICE"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user