From kde-commits Thu Dec 08 13:00:30 2016 From: Montel Laurent Date: Thu, 08 Dec 2016 13:00:30 +0000 To: kde-commits Subject: [messagelib] webengineviewer/src/checkphishingurl: Try to make it works Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=148120204617909 Git commit 9941cb0c85121029cf13e0943921e9b607b303a9 by Montel Laurent. Committed on 08/12/2016 at 13:00. Pushed by mlaurent into branch 'master'. Try to make it works M +8 -10 webengineviewer/src/checkphishingurl/autotests/riceencodingd= ecodertest.cpp M +4 -4 webengineviewer/src/checkphishingurl/riceencodingdecoder.cpp M +1 -1 webengineviewer/src/checkphishingurl/riceencodingdecoder.h https://commits.kde.org/messagelib/9941cb0c85121029cf13e0943921e9b607b303a9 diff --git a/webengineviewer/src/checkphishingurl/autotests/riceencodingdec= odertest.cpp b/webengineviewer/src/checkphishingurl/autotests/riceencodingd= ecodertest.cpp index 6b8b02f9..414034eb 100644 --- a/webengineviewer/src/checkphishingurl/autotests/riceencodingdecodertes= t.cpp +++ b/webengineviewer/src/checkphishingurl/autotests/riceencodingdecodertes= t.cpp @@ -80,35 +80,33 @@ void RiceEncodingDecoderTest::shouldDecodeRiceIndices() = void RiceEncodingDecoderTest::shouldDecodeRiceHashes_data() { - //TODO -#if 0 QTest::addColumn("firstValue"); QTest::addColumn("riceParameter"); QTest::addColumn("numberEntries"); QTest::addColumn("encodingData"); - QTest::addColumn("result"); - QTest::newRow("empty") << QByteArray() << 0 << 0 << QByteArray() << QB= yteArray(); - //TODO add more -#endif + QTest::addColumn >("result"); + QList r; + QTest::newRow("empty") << QByteArray() << 0 << 0 << QByteArray() << r; + r.clear(); + r =3D {5, 0xad934c0cu, 0x6ff67f56u, 0x81316fceu}; + QTest::newRow("test1") << QByteArrayLiteral("5") << 28 << 3 << QByteAr= rayLiteral("\xbf\xa8\x3f\xfb\xf\xf\x5e\x27\xe6\xc3\x1d\xc6\x38") << r; } = void RiceEncodingDecoderTest::shouldDecodeRiceHashes() { -#if 0 QFETCH(QByteArray, firstValue); QFETCH(int, riceParameter); QFETCH(int, numberEntries); QFETCH(QByteArray, encodingData); - QFETCH(QByteArray, result); + QFETCH(QList, result); WebEngineViewer::RiceEncodingDecoder decoding; WebEngineViewer::RiceDeltaEncoding deltaEncoding; deltaEncoding.encodingData =3D encodingData; deltaEncoding.firstValue =3D firstValue; deltaEncoding.numberEntries =3D numberEntries; deltaEncoding.riceParameter =3D riceParameter; - const QByteArray hash =3D decoding.decodeRiceHashesDelta(deltaEncoding= ); + const QList hash =3D decoding.decodeRiceHashesDelta(deltaEnco= ding); QCOMPARE(hash, result); -#endif } = QTEST_MAIN(RiceEncodingDecoderTest) diff --git a/webengineviewer/src/checkphishingurl/riceencodingdecoder.cpp b= /webengineviewer/src/checkphishingurl/riceencodingdecoder.cpp index ddd59acc..07762646 100644 --- a/webengineviewer/src/checkphishingurl/riceencodingdecoder.cpp +++ b/webengineviewer/src/checkphishingurl/riceencodingdecoder.cpp @@ -79,9 +79,9 @@ QList RiceEncodingDecoder::decodeRiceIndiceDelta(con= st RiceDeltaEncoding &r return list; } = -QList RiceEncodingDecoder::decodeRiceHashesDelta(const RiceDeltaEncod= ing &riceDeltaEncoding) +QList RiceEncodingDecoder::decodeRiceHashesDelta(const RiceDeltaE= ncoding &riceDeltaEncoding) { - QList list; + QList list; bool ok =3D false; quint64 firstValue =3D riceDeltaEncoding.firstValue.toInt(&ok); if (!ok) { @@ -99,7 +99,7 @@ QList RiceEncodingDecoder::decodeRiceHashesDelta(con= st RiceDeltaEncoding &r uint32_t offset; result =3D decoder.nextValue(&offset); if (!result) { - return QList(); + return QList(); } = lastValue +=3D offset; @@ -120,7 +120,7 @@ QList RiceEncodingDecoder::decodeRiceHashesDelta(c= onst RiceDeltaEncoding &r QByteArray ba; // This flipping is done so that when the vector is interpreted as a s= tring, // the bytes are in the correct order. - QList newList; + QList newList; newList.reserve(list.count()); const int listCount(list.count()); for (int i =3D 0; i < listCount; ++i) { diff --git a/webengineviewer/src/checkphishingurl/riceencodingdecoder.h b/w= ebengineviewer/src/checkphishingurl/riceencodingdecoder.h index a2ee742f..b9db1510 100644 --- a/webengineviewer/src/checkphishingurl/riceencodingdecoder.h +++ b/webengineviewer/src/checkphishingurl/riceencodingdecoder.h @@ -63,7 +63,7 @@ public: ~RiceEncodingDecoder(); = static QList decodeRiceIndiceDelta(const WebEngineViewer::RiceDel= taEncoding &riceDeltaEncoding); - static QList decodeRiceHashesDelta(const WebEngineViewer::RiceDel= taEncoding &riceDeltaEncoding); + static QList decodeRiceHashesDelta(const WebEngineViewer::Ric= eDeltaEncoding &riceDeltaEncoding); }; } =20