diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp b/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp index 59362d010af..7931363b4bd 100644 --- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp +++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp @@ -377,6 +377,8 @@ void runScenario() char chararray[3] = { 'H', 'i', '\0' }; const char constchararray[3] = { 'H', 'i', '\0' }; char achar = 'a'; + char embedded_NULs[16] = { 'H', 'i' }; + const char const_embedded_NULs[16] = { 'H', 'i' }; CHECK(P, bytearray, bytearray); CHECK(P, QByteArray(bytearray), bytearray); @@ -400,6 +402,33 @@ void runScenario() CHECK(P, bytearray, achar); CHECK(Q, bytearray, constchararray); CHECK(Q, bytearray, achar); + CHECK(Q, bytearray, embedded_NULs); + CHECK(Q, bytearray, const_embedded_NULs); + + CHECK(Q, baview, bytearray); + CHECK(Q, baview, charstar); + CHECK(Q, baview, chararray); + CHECK(Q, baview, constchararray); + CHECK(Q, baview, achar); + CHECK(Q, baview, embedded_NULs); + CHECK(Q, baview, const_embedded_NULs); + + // Check QString/QByteArray consistency when appending const char[] with embedded NULs: + { + const QByteArray ba = baview Q embedded_NULs; + QEXPECT_FAIL("", "QTBUG-117321", Continue); + QCOMPARE(ba.size(), baview.size() + q20::ssize(embedded_NULs) - 1); + +#ifndef QT_NO_CAST_FROM_ASCII + const auto l1s = QLatin1StringView{baview}; // l1string != baview + + const QString s = l1s Q embedded_NULs; + QCOMPARE(s.size(), l1s.size() + q20::ssize(embedded_NULs) - 1); + + QEXPECT_FAIL("", "QTBUG-117321", Continue); + QCOMPARE(s, ba); +#endif + } //CHECK(Q, charstar, charstar); // BUILTIN <-> BUILTIN cat't be overloaded //CHECK(Q, charstar, chararray); diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/tst_qstringbuilder1.cpp b/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/tst_qstringbuilder1.cpp index 394372c3985..e8365f500bb 100644 --- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/tst_qstringbuilder1.cpp +++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/tst_qstringbuilder1.cpp @@ -15,6 +15,8 @@ #include #include +#include + #define LITERAL "some literal" namespace { diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder2/tst_qstringbuilder2.cpp b/tests/auto/corelib/text/qstringbuilder/qstringbuilder2/tst_qstringbuilder2.cpp index dc590304f55..1aaee114a35 100644 --- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder2/tst_qstringbuilder2.cpp +++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder2/tst_qstringbuilder2.cpp @@ -16,6 +16,8 @@ #include #include +#include + #define LITERAL "some literal" namespace { diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder3/tst_qstringbuilder3.cpp b/tests/auto/corelib/text/qstringbuilder/qstringbuilder3/tst_qstringbuilder3.cpp index 3222b52713e..aaa14a5d1a2 100644 --- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder3/tst_qstringbuilder3.cpp +++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder3/tst_qstringbuilder3.cpp @@ -15,6 +15,8 @@ #include #include +#include + #define LITERAL "some literal" namespace { diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder4/tst_qstringbuilder4.cpp b/tests/auto/corelib/text/qstringbuilder/qstringbuilder4/tst_qstringbuilder4.cpp index 442c5275d2f..319708fd4b7 100644 --- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder4/tst_qstringbuilder4.cpp +++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder4/tst_qstringbuilder4.cpp @@ -16,6 +16,8 @@ #include #include +#include + #define LITERAL "some literal" namespace {