mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-04-05 05:27:39 +03:00
Test if we correctly detect errors when writing.
This commit is contained in:
parent
606e36acf3
commit
2033174d95
7 changed files with 158 additions and 7 deletions
|
@ -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"));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue