diff --git a/webengineviewer/src/checkphishingurl/autotests/riceencodingdecodertest.cpp b/webengineviewer/src/checkphishingurl/autotests/riceencodingdecodertest.cpp index 5841aeab..c17b976b 100644 --- a/webengineviewer/src/checkphishingurl/autotests/riceencodingdecodertest.cpp +++ b/webengineviewer/src/checkphishingurl/autotests/riceencodingdecodertest.cpp @@ -1,113 +1,113 @@ /* Copyright (C) 2016-2019 Laurent Montel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "riceencodingdecodertest.h" #include "../riceencodingdecoder.h" #include #include RiceEncodingDecoderTest::RiceEncodingDecoderTest(QObject *parent) : QObject(parent) { } RiceEncodingDecoderTest::~RiceEncodingDecoderTest() { } void RiceEncodingDecoderTest::shouldDecodeRiceIndices_data() { QTest::addColumn("firstValue"); QTest::addColumn("riceParameter"); QTest::addColumn("numberEntries"); QTest::addColumn("encodingData"); - QTest::addColumn >("result"); - QTest::newRow("empty") << QByteArray() << 0 << 0 << QByteArray() << QList(); - QList result; + QTest::addColumn >("result"); + QTest::newRow("empty") << QByteArray() << 0 << 0 << QByteArray() << QVector(); + QVector result; result << 3; QTest::newRow("zero value") << QByteArray("3") << 2 << 0 << QByteArray() << result; result.clear(); result << 5 << 20 << 29; QTest::newRow("test1") << QByteArray("5") << 2 << 2 << QByteArrayLiteral("\xf7\x2") << result; result.clear(); QTest::newRow("failedempty") << QByteArray("3") << 5 << 1 << QByteArray() << result; result.clear(); //TODO fixme //QTest::newRow("failednegativeentries") << QByteArray("3") << 5 << -1 << QByteArray() << result; result.clear(); //QTest::newRow("failednonpositive") << QByteArray("3") << 0 << 1 << QByteArrayLiteral("a") << result; result.clear(); QTest::newRow("failednonpositive1") << QByteArray("3") << -1 << 1 << QByteArrayLiteral("a") << result; } void RiceEncodingDecoderTest::shouldDecodeRiceIndices() { QFETCH(QByteArray, firstValue); QFETCH(int, riceParameter); QFETCH(int, numberEntries); QFETCH(QByteArray, encodingData); QFETCH(QVector, result); WebEngineViewer::RiceEncodingDecoder decoding; WebEngineViewer::RiceDeltaEncoding deltaEncoding; deltaEncoding.encodingData = encodingData; deltaEncoding.firstValue = firstValue; deltaEncoding.numberEntries = numberEntries; deltaEncoding.riceParameter = riceParameter; QVector list = decoding.decodeRiceIndiceDelta(deltaEncoding); QCOMPARE(list.count(), result.count()); QCOMPARE(list, result); } void RiceEncodingDecoderTest::shouldDecodeRiceHashes_data() { QTest::addColumn("firstValue"); QTest::addColumn("riceParameter"); QTest::addColumn("numberEntries"); QTest::addColumn("encodingData"); QTest::addColumn >("result"); QVector r; QTest::newRow("empty") << QByteArray() << 0 << 0 << QByteArray() << r; r.clear(); r = {5, 0xad934c0cu, 0x6ff67f56u, 0x81316fceu}; QTest::newRow("test1") << QByteArrayLiteral("5") << 28 << 3 << QByteArrayLiteral("\xbf\xa8\x3f\xfb\xf\xf\x5e\x27\xe6\xc3\x1d\xc6\x38") << r; } void RiceEncodingDecoderTest::shouldDecodeRiceHashes() { QFETCH(QByteArray, firstValue); QFETCH(int, riceParameter); QFETCH(int, numberEntries); QFETCH(QByteArray, encodingData); QFETCH(QVector, result); WebEngineViewer::RiceEncodingDecoder decoding; WebEngineViewer::RiceDeltaEncoding deltaEncoding; deltaEncoding.encodingData = encodingData; deltaEncoding.firstValue = firstValue; deltaEncoding.numberEntries = numberEntries; deltaEncoding.riceParameter = riceParameter; const QVector hash = decoding.decodeRiceHashesDelta(deltaEncoding); qDebug() << " hash " << hash << " 0xad934c0cu" << 0xad934c0cu; QCOMPARE(hash, result); } QTEST_MAIN(RiceEncodingDecoderTest)