summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/text/qstringbuilder
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/text/qstringbuilder')
-rw-r--r--tests/auto/corelib/text/qstringbuilder/qstringbuilder1/CMakeLists.txt2
-rw-r--r--tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp38
-rw-r--r--tests/auto/corelib/text/qstringbuilder/qstringbuilder2/CMakeLists.txt2
-rw-r--r--tests/auto/corelib/text/qstringbuilder/qstringbuilder3/CMakeLists.txt2
-rw-r--r--tests/auto/corelib/text/qstringbuilder/qstringbuilder4/CMakeLists.txt2
5 files changed, 16 insertions, 30 deletions
diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/CMakeLists.txt b/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/CMakeLists.txt
index 2c897ddcd3..2b28032657 100644
--- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/CMakeLists.txt
+++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/CMakeLists.txt
@@ -4,7 +4,7 @@
## tst_qstringbuilder1 Test:
#####################################################################
-qt_add_test(tst_qstringbuilder1
+qt_internal_add_test(tst_qstringbuilder1
SOURCES
tst_qstringbuilder1.cpp
)
diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp b/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp
index 5903c7066b..c1a208bc62 100644
--- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp
+++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp
@@ -38,12 +38,10 @@
#define UTF8_LITERAL_LEN (sizeof(UTF8_LITERAL)-1)
#define UTF8_LITERAL_EXTRA "s\xc3\xb6m\xc3\xab l\xc3\xaft\xc3\xabr\xc3\xa4l" "EXTRA"
-#ifdef Q_COMPILER_UNICODE_STRINGS
// "some literal", but replacing all vocals by their umlauted UTF-8 string :)
#define UNICODE_LITERAL u"s\u00f6m\u00eb l\u00eft\u00ebr\u00e4l"
#define UNICODE_LITERAL_LEN ((sizeof(UNICODE_LITERAL) - 1) / 2)
#define UNICODE_LITERAL_EXTRA u"s\u00f6m\u00eb l\u00eft\u00ebr\u00e4l" "EXTRA"
-#endif
#ifndef P
# error You need to define P
@@ -59,17 +57,14 @@
template <typename T> QString toQString(const T &t);
template <> QString toQString(const QString &s) { return s; }
-template <> QString toQString(const QStringRef &r) { return r.toString(); }
template <> QString toQString(const QStringView &v) { return v.toString(); }
template <> QString toQString(const QLatin1String &l) { return l; }
template <> QString toQString(const QLatin1Char &l) { return QChar(l); }
template <> QString toQString(const QChar &c) { return c; }
template <> QString toQString(const QChar::SpecialCharacter &c) { return QChar(c); }
-#ifdef Q_COMPILER_UNICODE_STRINGS
template <> QString toQString(char16_t * const &p) { return QStringView(p).toString(); }
template <size_t N> QString toQString(const char16_t (&a)[N]) { return QStringView(a).toString(); }
template <> QString toQString(const char16_t &c) { return QChar(c); }
-#endif
template <typename T> QByteArray toQByteArray(const T &t);
@@ -84,17 +79,14 @@ void runScenario()
// strings default to utf8.
QLatin1String l1string(LITERAL);
QString string(l1string);
- QStringRef stringref(&string, 2, 10);
- QStringView stringview(stringref);
+ QStringView stringview = QStringView{ string }.mid(2, 10);
QLatin1Char lchar('c');
QChar qchar(lchar);
QChar::SpecialCharacter special(QChar::Nbsp);
-#ifdef Q_COMPILER_UNICODE_STRINGS
char16_t u16char = UNICODE_LITERAL[0];
char16_t u16chararray[] = { u's', 0xF6, u'm', 0xEB, u' ', u'l', 0xEF, u't', 0xEB, u'r', 0xE4, u'l', 0x00 };
QCOMPARE(QStringView(u16chararray), QStringView(UNICODE_LITERAL));
char16_t *u16charstar = u16chararray;
-#endif
#define CHECK(QorP, a1, a2) \
do { \
@@ -109,7 +101,6 @@ void runScenario()
CHECK(P, l1string, l1string);
CHECK(P, l1string, string);
- CHECK(P, l1string, stringref);
CHECK(Q, l1string, stringview);
CHECK(P, l1string, lchar);
CHECK(P, l1string, qchar);
@@ -120,7 +111,6 @@ void runScenario()
CHECK(Q, l1string, u16charstar);
CHECK(P, string, string);
- CHECK(P, string, stringref);
CHECK(Q, string, stringview);
CHECK(P, string, lchar);
CHECK(P, string, qchar);
@@ -130,16 +120,6 @@ void runScenario()
CHECK(Q, string, u16chararray);
CHECK(Q, string, u16charstar);
- CHECK(P, stringref, stringref);
- CHECK(Q, stringref, stringview);
- CHECK(P, stringref, lchar);
- CHECK(P, stringref, qchar);
- CHECK(P, stringref, special);
- CHECK(P, stringref, QStringLiteral(LITERAL));
- CHECK(Q, stringref, u16char);
- CHECK(Q, stringref, u16chararray);
- CHECK(Q, stringref, u16charstar);
-
CHECK(Q, stringview, stringview);
CHECK(Q, stringview, lchar);
CHECK(Q, stringview, qchar);
@@ -191,7 +171,7 @@ void runScenario()
toQByteArray(a1).append(toQByteArray(a2))) \
/* end */
- QByteArray bytearray = stringref.toUtf8();
+ QByteArray bytearray = stringview.toUtf8();
char *charstar = bytearray.data();
char chararray[3] = { 'H', 'i', '\0' };
const char constchararray[3] = { 'H', 'i', '\0' };
@@ -224,15 +204,13 @@ void runScenario()
QString r;
// self-assignment:
- r = stringref.toString();
+ r = stringview.toString();
r = lchar + r;
- QCOMPARE(r, QString(lchar P stringref));
+ QCOMPARE(r, QString(lchar P stringview));
-#ifdef Q_COMPILER_UNICODE_STRINGS
r = QStringLiteral(UNICODE_LITERAL);
r = r Q QStringLiteral(UNICODE_LITERAL);
QCOMPARE(r, r3);
-#endif
#ifndef QT_NO_CAST_FROM_ASCII
r = string P LITERAL;
@@ -358,6 +336,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\"");
}
}
diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder2/CMakeLists.txt b/tests/auto/corelib/text/qstringbuilder/qstringbuilder2/CMakeLists.txt
index 7b5b96aef3..274be115d9 100644
--- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder2/CMakeLists.txt
+++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder2/CMakeLists.txt
@@ -4,7 +4,7 @@
## tst_qstringbuilder2 Test:
#####################################################################
-qt_add_test(tst_qstringbuilder2
+qt_internal_add_test(tst_qstringbuilder2
SOURCES
tst_qstringbuilder2.cpp
)
diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder3/CMakeLists.txt b/tests/auto/corelib/text/qstringbuilder/qstringbuilder3/CMakeLists.txt
index 3293f26e5c..a1c4298f99 100644
--- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder3/CMakeLists.txt
+++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder3/CMakeLists.txt
@@ -4,7 +4,7 @@
## tst_qstringbuilder3 Test:
#####################################################################
-qt_add_test(tst_qstringbuilder3
+qt_internal_add_test(tst_qstringbuilder3
SOURCES
tst_qstringbuilder3.cpp
)
diff --git a/tests/auto/corelib/text/qstringbuilder/qstringbuilder4/CMakeLists.txt b/tests/auto/corelib/text/qstringbuilder/qstringbuilder4/CMakeLists.txt
index 55c4400acf..b0dbcbf83a 100644
--- a/tests/auto/corelib/text/qstringbuilder/qstringbuilder4/CMakeLists.txt
+++ b/tests/auto/corelib/text/qstringbuilder/qstringbuilder4/CMakeLists.txt
@@ -4,7 +4,7 @@
## tst_qstringbuilder4 Test:
#####################################################################
-qt_add_test(tst_qstringbuilder4
+qt_internal_add_test(tst_qstringbuilder4
SOURCES
tst_qstringbuilder4.cpp
)