summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qchar
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2017-03-14 11:07:54 +0100
committerMarc Mutz <marc.mutz@kdab.com>2017-03-17 01:14:54 +0000
commit208c71768cca1dda9ea42f3a395889a85810005e (patch)
treea30ba9232363c845b24ac47206fc2106074feed4 /tests/auto/corelib/tools/qchar
parent4351c2af45768bcb68b5bb996c1fb6e24dc9556b (diff)
QChar: add (char16_t) and (wchar_t) ctors
... for better std C++ integration. [ChangeLog][QtCore][QChar] Added constructors from char16_t and, on Windows, wchar_t. Change-Id: I2d18ea3a37e869b8ea9f4036d7200d9d13c7d929 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/tools/qchar')
-rw-r--r--tests/auto/corelib/tools/qchar/tst_qchar.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qchar/tst_qchar.cpp b/tests/auto/corelib/tools/qchar/tst_qchar.cpp
index 13898ace7b..dede56b4bf 100644
--- a/tests/auto/corelib/tools/qchar/tst_qchar.cpp
+++ b/tests/auto/corelib/tools/qchar/tst_qchar.cpp
@@ -36,6 +36,8 @@ class tst_QChar : public QObject
{
Q_OBJECT
private slots:
+ void fromChar16_t();
+ void fromWchar_t();
void operator_eqeq_int();
void operators_data();
void operators();
@@ -75,6 +77,30 @@ private slots:
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
+void tst_QChar::fromChar16_t()
+{
+#if !defined(Q_OS_WIN) || defined(Q_COMPILER_UNICODE_STRINGS)
+ QChar aUmlaut = u'\u00E4'; // German small letter a-umlaut
+ QCOMPARE(aUmlaut, QChar(0xE4));
+ QChar replacementCharacter = u'\uFFFD';
+ QCOMPARE(replacementCharacter, QChar(QChar::ReplacementCharacter));
+#else
+ QSKIP("This test requires C++11 char16_t support enabled in the compiler.");
+#endif
+}
+
+void tst_QChar::fromWchar_t()
+{
+#if defined(Q_OS_WIN)
+ QChar aUmlaut = L'\u00E4'; // German small letter a-umlaut
+ QCOMPARE(aUmlaut, QChar(0xE4));
+ QChar replacementCharacter = L'\uFFFD';
+ QCOMPARE(replacementCharacter, QChar(QChar::ReplacementCharacter));
+#else
+ QSKIP("This is a Windows-only test.");
+#endif
+}
+
void tst_QChar::operator_eqeq_int()
{
{