summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2020-09-01 09:07:09 +0200
committerMårten Nordheim <marten.nordheim@qt.io>2020-09-02 23:10:21 +0200
commitb98b7de0da395be33e2d1646ac62075422ce4343 (patch)
tree43f5f07eaf5cdba36745ed32ff29383eb8cdbc46 /tests
parent39e07ebf64e115460e2a7573c13dde014c8e33ca (diff)
QByteArray: Disregard space at front during ::reserve(...)
Traditionally when calling reserve it's because you expect to append up to X amount of bytes. We should keep that behavior the same. With another patch still in the works current behavior caused an issue with QStringBuilder in QNAM, as mirrored in the testcase attached. Change-Id: I9792a8f158fc9235e3de48ac8b06ac2c10e7f3dc Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp b/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp
index b811c63036..e0a261efd0 100644
--- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp
+++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp
@@ -344,6 +344,14 @@ void runScenario()
QByteArray ba2 = withZero;
ba2 += ba2 P withZero;
QCOMPARE(ba2, QByteArray(withZero + withZero + withZero));
+
+ // With space allocated in front, mirroring what happens with QHttpMultiPart in QNAM
+ QByteArray byteArray;
+ byteArray.reserve(70);
+ byteArray.insert(0, "multipart/");
+ byteArray.insert(byteArray.size(), "mixed");
+ byteArray += "; boundary=\"" P QByteArray(30, 'o') P '"';
+ QCOMPARE(byteArray, "multipart/mixed; boundary=\"oooooooooooooooooooooooooooooo\"");
}
}