diff options
author | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2019-03-01 16:17:57 +0100 |
---|---|---|
committer | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2019-03-04 16:18:14 +0000 |
commit | ef5aefb062bf8cbfb764f2deba731d3d64069099 (patch) | |
tree | 8934fafccd7afa4f90d8743f1a7c0ce4c5bc3b16 /tests | |
parent | 47bb74fd156edb93d85c88db4d6ff98648bce275 (diff) |
Hpack - fix the static lookup
'accept' breaks the order, making the static table unsorted and thus
std::lower_bound cannot find it and we always index it in a dynamic
table. Also, make this static table accessible to auto-test.
Plus fix some warnings quite annoyingly visible in qt-creator.
Fixes: QTBUG-74161
Change-Id: I47410f2ef974ac92797c9804aa55cb5c36a436c4
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/network/access/hpack/tst_hpack.cpp | 49 |
1 files changed, 13 insertions, 36 deletions
diff --git a/tests/auto/network/access/hpack/tst_hpack.cpp b/tests/auto/network/access/hpack/tst_hpack.cpp index 810745a065..d5e359db57 100644 --- a/tests/auto/network/access/hpack/tst_hpack.cpp +++ b/tests/auto/network/access/hpack/tst_hpack.cpp @@ -57,7 +57,6 @@ private Q_SLOTS: void lookupTableConstructor(); - void lookupTableStatic_data(); void lookupTableStatic(); void lookupTableDynamic(); @@ -126,7 +125,7 @@ void tst_Hpack::bitstreamConstruction() // 'Read' some data back: for (int i = 0; i < size; ++i) { uchar bitPattern = 0; - const auto bitsRead = in.peekBits(i * 8, 8, &bitPattern); + const auto bitsRead = in.peekBits(quint64(i * 8), 8, &bitPattern); QVERIFY(bitsRead == 8); QVERIFY(bitPattern == bytes[i]); } @@ -282,7 +281,7 @@ void tst_Hpack::bitstreamCompression() const auto start = QRandomGenerator::global()->bounded(uint(bytes.length()) / 2); auto end = start * 2; if (!end) - end = bytes.length() / 2; + end = unsigned(bytes.length() / 2); strings.push_back(bytes.substr(start, end - start)); const auto &s = strings.back(); totalStringBytes += s.size(); @@ -384,43 +383,21 @@ void tst_Hpack::lookupTableConstructor() } } -void tst_Hpack::lookupTableStatic_data() -{ - QTest::addColumn<QByteArray>("expectedName"); - QTest::addColumn<QByteArray>("expectedValue"); - - // Some predefined fields to find - // (they are always defined/required by HPACK). - QTest::newRow(":authority|") << QByteArray(":authority") << QByteArray(""); - QTest::newRow(":method|GET") << QByteArray(":method") << QByteArray("GET"); - QTest::newRow(":method|POST") << QByteArray(":method") << QByteArray("POST"); - QTest::newRow(":path|/") << QByteArray(":path") << QByteArray("/"); - QTest::newRow(":path|/index.html") << QByteArray(":path") << QByteArray("/index.html"); - QTest::newRow(":scheme|http") << QByteArray(":scheme") << QByteArray("http"); - QTest::newRow(":scheme|https") << QByteArray(":scheme") << QByteArray("https"); - QTest::newRow(":status|200") << QByteArray(":status") << QByteArray("200"); - QTest::newRow(":status|204") << QByteArray(":status") << QByteArray("204"); - QTest::newRow(":status|206") << QByteArray(":status") << QByteArray("206"); - QTest::newRow(":status|304") << QByteArray(":status") << QByteArray("304"); - QTest::newRow(":status|400") << QByteArray(":status") << QByteArray("400"); - QTest::newRow(":status|404") << QByteArray(":status") << QByteArray("404"); - QTest::newRow(":status|500") << QByteArray(":status") << QByteArray("500"); -} - void tst_Hpack::lookupTableStatic() { const FieldLookupTable table(0, false /*all static, no need in 'search index'*/); - - QFETCH(QByteArray, expectedName); - QFETCH(QByteArray, expectedValue); - - const quint32 index = table.indexOf(expectedName, expectedValue); - QVERIFY(index != 0); - + const auto &staticTable = FieldLookupTable::staticPart(); QByteArray name, value; - QVERIFY(table.field(index, &name, &value)); - QCOMPARE(name, expectedName); - QCOMPARE(value, expectedValue); + quint32 currentIndex = 1; // HPACK is indexing starting from 1. + for (const HeaderField &field : staticTable) { + const quint32 index = table.indexOf(field.name, field.value); + QVERIFY(index != 0); + QCOMPARE(index, currentIndex); + QVERIFY(table.field(index, &name, &value)); + QCOMPARE(name, field.name); + QCOMPARE(value, field.value); + ++currentIndex; + } } void tst_Hpack::lookupTableDynamic() |