[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [messagelib] webengineviewer/src/checkphishingurl: Try to make it works
From:       Montel Laurent <montel () kde ! org>
Date:       2016-12-08 13:00:30
Message-ID: E1cEyJK-0002Y6-OE () code ! kde ! org
[Download RAW message or body]

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/riceencodingdecodertest.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/riceencodingdecodertest.cpp \
b/webengineviewer/src/checkphishingurl/autotests/riceencodingdecodertest.cpp index \
                6b8b02f9..414034eb 100644
--- a/webengineviewer/src/checkphishingurl/autotests/riceencodingdecodertest.cpp
+++ b/webengineviewer/src/checkphishingurl/autotests/riceencodingdecodertest.cpp
@@ -80,35 +80,33 @@ void RiceEncodingDecoderTest::shouldDecodeRiceIndices()
 
 void RiceEncodingDecoderTest::shouldDecodeRiceHashes_data()
 {
-    //TODO
-#if 0
     QTest::addColumn<QByteArray>("firstValue");
     QTest::addColumn<int>("riceParameter");
     QTest::addColumn<int>("numberEntries");
     QTest::addColumn<QByteArray>("encodingData");
-    QTest::addColumn<QByteArray >("result");
-    QTest::newRow("empty") << QByteArray() << 0 << 0 << QByteArray() << \
                QByteArray();
-    //TODO add more
-#endif
+    QTest::addColumn<QList<quint32> >("result");
+    QList<quint32> 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()
 {
-#if 0
     QFETCH(QByteArray, firstValue);
     QFETCH(int, riceParameter);
     QFETCH(int, numberEntries);
     QFETCH(QByteArray, encodingData);
-    QFETCH(QByteArray, result);
+    QFETCH(QList<quint32>, result);
     WebEngineViewer::RiceEncodingDecoder decoding;
     WebEngineViewer::RiceDeltaEncoding deltaEncoding;
     deltaEncoding.encodingData = encodingData;
     deltaEncoding.firstValue = firstValue;
     deltaEncoding.numberEntries = numberEntries;
     deltaEncoding.riceParameter = riceParameter;
-    const QByteArray hash = decoding.decodeRiceHashesDelta(deltaEncoding);
+    const QList<quint32> hash = decoding.decodeRiceHashesDelta(deltaEncoding);
     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<int> RiceEncodingDecoder::decodeRiceIndiceDelta(const \
RiceDeltaEncoding &r  return list;
 }
 
-QList<int> RiceEncodingDecoder::decodeRiceHashesDelta(const RiceDeltaEncoding \
&riceDeltaEncoding) +QList<quint32> RiceEncodingDecoder::decodeRiceHashesDelta(const \
RiceDeltaEncoding &riceDeltaEncoding)  {
-    QList<int> list;
+    QList<quint32> list;
     bool ok = false;
     quint64 firstValue = riceDeltaEncoding.firstValue.toInt(&ok);
     if (!ok) {
@@ -99,7 +99,7 @@ QList<int> RiceEncodingDecoder::decodeRiceHashesDelta(const \
RiceDeltaEncoding &r  uint32_t offset;
         result = decoder.nextValue(&offset);
         if (!result) {
-            return QList<int>();
+            return QList<quint32>();
         }
 
         lastValue += offset;
@@ -120,7 +120,7 @@ QList<int> RiceEncodingDecoder::decodeRiceHashesDelta(const \
RiceDeltaEncoding &r  QByteArray ba;
     // This flipping is done so that when the vector is interpreted as a string,
     // the bytes are in the correct order.
-    QList<int> newList;
+    QList<quint32> newList;
     newList.reserve(list.count());
     const int listCount(list.count());
     for (int i = 0; i < listCount; ++i) {
diff --git a/webengineviewer/src/checkphishingurl/riceencodingdecoder.h \
b/webengineviewer/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<int> decodeRiceIndiceDelta(const WebEngineViewer::RiceDeltaEncoding \
                &riceDeltaEncoding);
-    static QList<int> decodeRiceHashesDelta(const WebEngineViewer::RiceDeltaEncoding \
&riceDeltaEncoding); +    static QList<quint32> decodeRiceHashesDelta(const \
WebEngineViewer::RiceDeltaEncoding &riceDeltaEncoding);  };
 }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic