summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/io/qdebug/tst_qdebug.cpp67
-rw-r--r--tests/auto/testlib/selftests/expected_badxml.lightxml2
-rw-r--r--tests/auto/testlib/selftests/expected_badxml.xml2
-rw-r--r--tests/auto/testlib/selftests/expected_badxml.xunitxml4
4 files changed, 71 insertions, 4 deletions
diff --git a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
index 015a13775d..63de953437 100644
--- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
+++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
@@ -52,6 +52,7 @@ private slots:
void stateSaver() const;
void veryLongWarningMessage() const;
void qDebugQChar() const;
+ void qDebugQString() const;
void qDebugQStringRef() const;
void qDebugQLatin1String() const;
void qDebugQByteArray() const;
@@ -344,6 +345,54 @@ void tst_QDebug::qDebugQChar() const
}
+void tst_QDebug::qDebugQString() const
+{
+ /* Use a basic string. */
+ {
+ QString file, function;
+ int line = 0;
+ const QString in(QLatin1String("input"));
+ const QStringRef inRef(&in);
+
+ MessageHandlerSetter mhs(myMessageHandler);
+ { qDebug() << inRef; }
+#ifndef QT_NO_MESSAGELOGCONTEXT
+ file = __FILE__; line = __LINE__ - 2; function = Q_FUNC_INFO;
+#endif
+ QCOMPARE(s_msgType, QtDebugMsg);
+ QCOMPARE(s_msg, QString::fromLatin1("\"input\""));
+ QCOMPARE(QString::fromLatin1(s_file), file);
+ QCOMPARE(s_line, line);
+ QCOMPARE(QString::fromLatin1(s_function), function);
+ }
+
+ /* simpler tests from now on */
+ MessageHandlerSetter mhs(myMessageHandler);
+
+ QString string = "Hello";
+ qDebug() << string;
+ QCOMPARE(s_msg, QString("\"Hello\""));
+
+ qDebug().noquote().nospace() << string;
+ QCOMPARE(s_msg, string);
+
+ qDebug().noquote().nospace() << qSetFieldWidth(8) << string;
+ QCOMPARE(s_msg, " " + string);
+
+ string = QLatin1String("\nSm\xF8rg\xE5sbord\\");
+ qDebug().noquote().nospace() << string;
+ QCOMPARE(s_msg, string);
+
+ qDebug() << string;
+ QCOMPARE(s_msg, QString("\"\\nSm\\u00F8rg\\u00E5sbord\\\\\""));
+
+ // surrogate pairs (including broken pairings)
+ ushort utf16[] = { 0xDC00, 0xD800, 0xDC00, 'x', 0xD800, 0xDC00, 0xD800, 0 };
+ string = QString::fromUtf16(utf16);
+ qDebug() << string;
+ QCOMPARE(s_msg, QString("\"\\uDC00\\U00010000x\\U00010000\\uD800\""));
+}
+
void tst_QDebug::qDebugQStringRef() const
{
/* Use a basic string. */
@@ -403,6 +452,24 @@ void tst_QDebug::qDebugQLatin1String() const
QCOMPARE(QString::fromLatin1(s_file), file);
QCOMPARE(s_line, line);
QCOMPARE(QString::fromLatin1(s_function), function);
+
+ /* simpler tests from now on */
+ QLatin1String string("\"Hello\"");
+ qDebug() << string;
+ QCOMPARE(s_msg, QString("\"\\\"Hello\\\"\""));
+
+ qDebug().noquote().nospace() << string;
+ QCOMPARE(s_msg, QString(string));
+
+ qDebug().noquote().nospace() << qSetFieldWidth(8) << string;
+ QCOMPARE(s_msg, " " + QString(string));
+
+ string = QLatin1String("\nSm\xF8rg\xE5sbord\\");
+ qDebug().noquote().nospace() << string;
+ QCOMPARE(s_msg, QString(string));
+
+ qDebug() << string;
+ QCOMPARE(s_msg, QString("\"\\nSm\\u00F8rg\\u00E5sbord\\\\\""));
}
void tst_QDebug::qDebugQByteArray() const
diff --git a/tests/auto/testlib/selftests/expected_badxml.lightxml b/tests/auto/testlib/selftests/expected_badxml.lightxml
index 94f479a79a..e0de44f0be 100644
--- a/tests/auto/testlib/selftests/expected_badxml.lightxml
+++ b/tests/auto/testlib/selftests/expected_badxml.lightxml
@@ -113,7 +113,7 @@
</TestFunction>
<TestFunction name="encoding">
<Message type="qdebug" file="" line="0">
- <Description><![CDATA["Ülrich Ümläut"]]></Description>
+ <Description><![CDATA["\u00DClrich \u00DCml\u00E4ut"]]></Description>
</Message>
<Incident type="pass" file="" line="0" />
<Duration msecs="0"/>
diff --git a/tests/auto/testlib/selftests/expected_badxml.xml b/tests/auto/testlib/selftests/expected_badxml.xml
index c1266bfeed..8667c2d9cd 100644
--- a/tests/auto/testlib/selftests/expected_badxml.xml
+++ b/tests/auto/testlib/selftests/expected_badxml.xml
@@ -115,7 +115,7 @@
</TestFunction>
<TestFunction name="encoding">
<Message type="qdebug" file="" line="0">
- <Description><![CDATA["Ülrich Ümläut"]]></Description>
+ <Description><![CDATA["\u00DClrich \u00DCml\u00E4ut"]]></Description>
</Message>
<Incident type="pass" file="" line="0" />
<Duration msecs="0"/>
diff --git a/tests/auto/testlib/selftests/expected_badxml.xunitxml b/tests/auto/testlib/selftests/expected_badxml.xunitxml
index 49048fdad6..46f4be4391 100644
--- a/tests/auto/testlib/selftests/expected_badxml.xunitxml
+++ b/tests/auto/testlib/selftests/expected_badxml.xunitxml
@@ -30,7 +30,7 @@
<failure message="failure message" result="fail"/>
</testcase>
<testcase result="pass" name="encoding">
- <!-- message="&quot;Ülrich Ümläut&quot;" type="qdebug" -->
+ <!-- message="&quot;\u00DClrich \u00DCml\u00E4ut&quot;" type="qdebug" -->
</testcase>
<testcase result="pass" name="cleanupTestCase"/>
<system-err>
@@ -46,6 +46,6 @@
<![CDATA[quotes " text" more text]]>
<![CDATA[xml close > open < tags < text]]>
<![CDATA[all > " mixed ]]]><![CDATA[]> up > " in < the ]]]><![CDATA[]> hopes < of triggering "< ]]]><![CDATA[]> bugs]]>
-<![CDATA["Ülrich Ümläut"]]>
+<![CDATA["\u00DClrich \u00DCml\u00E4ut"]]>
</system-err>
</testsuite>