summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2017-03-30 20:06:22 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2018-01-08 09:41:38 +0000
commit641e010cc7b52b6c3ac213e151781ffcbdd89145 (patch)
treeb8128a654a2250ff8a8b891ac668b37bbf253744 /tests/auto/corelib
parent6d0c8825f9bee01e4962a82d78a310e11ae8d17c (diff)
QStringBuilder: add support for char16_t{,*,[]}
[ChangeLog][QtCore][QStringBuilder] Added support for char16_t characters and strings. Change-Id: Iee727f07226f2a326ae0df28d44930336cd8f71e Reviewed-by: Milian Wolff <milian.wolff@kdab.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r--tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp
index 32fb321931..4f7b05530c 100644
--- a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp
+++ b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp
@@ -64,6 +64,11 @@ 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);
@@ -82,6 +87,12 @@ void runScenario()
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 { \
@@ -101,6 +112,9 @@ void runScenario()
CHECK(P, l1string, qchar);
CHECK(P, l1string, special);
CHECK(P, l1string, QStringLiteral(LITERAL));
+ CHECK(Q, l1string, u16char);
+ CHECK(Q, l1string, u16chararray);
+ CHECK(Q, l1string, u16charstar);
CHECK(P, string, string);
CHECK(P, string, stringref);
@@ -108,26 +122,53 @@ void runScenario()
CHECK(P, string, qchar);
CHECK(P, string, special);
CHECK(P, string, QStringLiteral(LITERAL));
+ CHECK(Q, string, u16char);
+ CHECK(Q, string, u16chararray);
+ CHECK(Q, string, u16charstar);
CHECK(P, stringref, stringref);
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(P, lchar, lchar);
CHECK(P, lchar, qchar);
CHECK(P, lchar, special);
CHECK(P, lchar, QStringLiteral(LITERAL));
+ CHECK(Q, lchar, u16char);
+ CHECK(Q, lchar, u16chararray);
+ CHECK(Q, lchar, u16charstar);
CHECK(P, qchar, qchar);
CHECK(P, qchar, special);
CHECK(P, qchar, QStringLiteral(LITERAL));
+ CHECK(Q, qchar, u16char);
+ CHECK(Q, qchar, u16chararray);
+ CHECK(Q, qchar, u16charstar);
CHECK(P, special, special);
CHECK(P, special, QStringLiteral(LITERAL));
+ CHECK(Q, special, u16char);
+ CHECK(Q, special, u16chararray);
+ CHECK(Q, special, u16charstar);
CHECK(P, QStringLiteral(LITERAL), QStringLiteral(LITERAL));
+ CHECK(Q, QStringLiteral(LITERAL), u16char);
+ CHECK(Q, QStringLiteral(LITERAL), u16chararray);
+ CHECK(Q, QStringLiteral(LITERAL), u16charstar);
+
+ // CHECK(Q, u16char, u16char); // BUILTIN <-> BUILTIN cat't be overloaded
+ // CHECK(Q, u16char, u16chararray);
+ // CHECK(Q, u16char, u16charstar);
+
+ // CHECK(Q, u16chararray, u16chararray); // BUILTIN <-> BUILTIN cat't be overloaded
+ // CHECK(Q, u16chararray, u16charstar);
+
+ // CHECK(Q, u16charstar, u16charstar); // BUILTIN <-> BUILTIN cat't be overloaded
#undef DO