summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/serialization/cborlargedatavalidation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/serialization/cborlargedatavalidation.cpp')
-rw-r--r--tests/auto/corelib/serialization/cborlargedatavalidation.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/tests/auto/corelib/serialization/cborlargedatavalidation.cpp b/tests/auto/corelib/serialization/cborlargedatavalidation.cpp
index 9abfe0f575..f3b6893957 100644
--- a/tests/auto/corelib/serialization/cborlargedatavalidation.cpp
+++ b/tests/auto/corelib/serialization/cborlargedatavalidation.cpp
@@ -81,19 +81,31 @@ qint64 LargeIODevice::readData(char *data, qint64 maxlen)
void addValidationLargeData(qsizetype minInvalid, qsizetype maxInvalid)
{
- char toolong[2 + sizeof(qsizetype)] = { char(0x81) };
+ char toolong[1 + sizeof(qsizetype)];
for (qsizetype v = maxInvalid; v >= minInvalid; --v) {
// 0x5a for 32-bit, 0x5b for 64-bit
- toolong[1] = sizeof(v) > 4 ? 0x5b : 0x5a;
- qToBigEndian(v, toolong + 2);
+ toolong[0] = sizeof(v) > 4 ? 0x5b : 0x5a;
+ qToBigEndian(v, toolong + 1);
QTest::addRow("bytearray-too-big-for-qbytearray-%llx", v)
<< QByteArray(toolong, sizeof(toolong)) << 0 << CborErrorDataTooLarge;
- toolong[1] |= 0x20;
+ QTest::addRow("bytearray-chunked-too-big-for-qbytearray-%llx", v)
+ << ('\x5f' + QByteArray(toolong, sizeof(toolong)) + '\xff')
+ << 0 << CborErrorDataTooLarge;
+ QTest::addRow("bytearray-2chunked-too-big-for-qbytearray-%llx", v)
+ << ("\x5f\x40" + QByteArray(toolong, sizeof(toolong)) + '\xff')
+ << 0 << CborErrorDataTooLarge;
+ toolong[0] |= 0x20;
// QCborStreamReader::readString copies to a QByteArray first
QTest::addRow("string-too-big-for-qbytearray-%llx", v)
<< QByteArray(toolong, sizeof(toolong)) << 0 << CborErrorDataTooLarge;
+ QTest::addRow("string-chunked-too-big-for-qbytearray-%llx", v)
+ << ('\x7f' + QByteArray(toolong, sizeof(toolong)) + '\xff')
+ << 0 << CborErrorDataTooLarge;
+ QTest::addRow("string-2chunked-too-big-for-qbytearray-%llx", v)
+ << ("\x7f\x60" + QByteArray(toolong, sizeof(toolong)) + '\xff')
+ << 0 << CborErrorDataTooLarge;
}
}