Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Checksum validator unit tests.
Signed-off-by: alex-z <[email protected]>
  • Loading branch information
allexzander committed Jan 11, 2022
commit 5b0e2d8ed071d6fb7d0ff9152c089df093740bee
5 changes: 4 additions & 1 deletion test/testchecksumvalidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ using namespace OCC::Utility;
QTemporaryDir _root;
QString _testfile;
QString _expectedError;
ValidateChecksumHeader::FailureReason _expectedFailureReason = ValidateChecksumHeader::FailureReason::Success;
QByteArray _expected;
QByteArray _expectedType;
bool _successDown;
Expand All @@ -44,8 +45,8 @@ using namespace OCC::Utility;

void slotDownError(const QString &errMsg, ValidateChecksumHeader::FailureReason reason)
{
Q_UNUSED(reason);
QCOMPARE(_expectedError, errMsg);
QCOMPARE(_expectedFailureReason, reason);
_errorSeen = true;
}

Expand Down Expand Up @@ -199,12 +200,14 @@ using namespace OCC::Utility;
QTRY_VERIFY(_successDown);

_expectedError = QStringLiteral("The downloaded file does not match the checksum, it will be resumed. \"543345\" != \"%1\"").arg(QString::fromUtf8(_expected));
_expectedFailureReason = ValidateChecksumHeader::FailureReason::ChecksumMismatch;
_errorSeen = false;
file->seek(0);
vali->start(_testfile, "Adler32:543345");
QTRY_VERIFY(_errorSeen);

_expectedError = QLatin1String("The checksum header contained an unknown checksum type \"Klaas32\"");
_expectedFailureReason = ValidateChecksumHeader::FailureReason::ChecksumTypeUnknown;
_errorSeen = false;
file->seek(0);
vali->start(_testfile, "Klaas32:543345");
Expand Down