summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qdebug
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2015-07-31 17:26:07 -0700
committerThiago Macieira <thiago.macieira@intel.com>2015-08-06 04:53:38 +0000
commit644ac04af0c3ef7d20ddc6077f85547fcba8caf5 (patch)
tree2d1b24aa90c1abd550eeacf777beaa600db1e60d /tests/auto/corelib/io/qdebug
parent007ad9e859711f36fb9c6d3b1d32acb5a3825691 (diff)
Change how QDebug escapes QStrings in the output
[ChangeLog][Important Behavior Changes] QDebug output for QStrings changed compared to Qt 5.5.0 to more closely match the output of previous Qt versions. Like Qt 5.5.0, QDebug will escape non-printable characters, the backslash and quote characters, but will no longer escape the printable characters. Task-number: QTBUG-47316 Change-Id: I52dd43c12685407bb9a6ffff13f62ef68cbc80c5 Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Diffstat (limited to 'tests/auto/corelib/io/qdebug')
-rw-r--r--tests/auto/corelib/io/qdebug/tst_qdebug.cpp40
1 files changed, 35 insertions, 5 deletions
diff --git a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
index 4e5cfed019..3e19e816c9 100644
--- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
+++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
@@ -379,18 +379,48 @@ void tst_QDebug::qDebugQString() const
qDebug().noquote().nospace() << qSetFieldWidth(8) << string;
QCOMPARE(s_msg, " " + string);
- string = QLatin1String("\nSm\xF8rg\xE5sbord\\");
+ string = "Sm\xc3\xb8rg\xc3\xa5sbord " // Latin script
+ "\xce\x91\xce\xb8\xce\xae\xce\xbd\xce\xb1 " // Greek script
+ "\xd0\x9c\xd0\xbe\xd1\x81\xd0\xba\xd0\xb2\xd0\xb0"; // Cyrillic script
qDebug().noquote().nospace() << string;
QCOMPARE(s_msg, string);
+ // This string only contains printable characters
qDebug() << string;
- QCOMPARE(s_msg, QString("\"\\nSm\\u00F8rg\\u00E5sbord\\\\\""));
+ QCOMPARE(s_msg, '"' + string + '"');
+
+ string = "\n\t\\\"";
+ qDebug().noquote().nospace() << string;
+ QCOMPARE(s_msg, string);
+
+ // This string only contains characters that must be escaped
+ qDebug() << string;
+ QCOMPARE(s_msg, QString("\"\\n\\t\\\\\\\"\""));
+
+ // Unicode escapes, BMP
+ string = "\1" // U+0001: START OF HEADING (category Cc)
+ "\x7f" // U+007F: DELETE (category Cc)
+ "\xc2\xad" // U+00AD: SOFT HYPHEN (category Cf)
+ "\xef\xbb\xbf"; // U+FEFF: ZERO WIDTH NO-BREAK SPACE / BOM (category Cf)
+ qDebug() << string;
+ QCOMPARE(s_msg, QString("\"\\u0001\\u007F\\u00AD\\uFEFF\""));
+
+ // Unicode printable non-BMP
+ string = "\xf0\x90\x80\x80"; // U+10000: LINEAR B SYLLABLE B008 A (category Lo)
+ qDebug() << string;
+ QCOMPARE(s_msg, '"' + string + '"');
+
+ // non-BMP and non-printable
+ string = "\xf3\xa0\x80\x81 " // U+E0001: LANGUAGE TAG (category Cf)
+ "\xf4\x80\x80\x80"; // U+100000: Plane 16 Private Use (category Co)
+ qDebug() << string;
+ QCOMPARE(s_msg, QString("\"\\U000E0001 \\U00100000\""));
- // surrogate pairs (including broken pairings)
- ushort utf16[] = { 0xDC00, 0xD800, 0xDC00, 'x', 0xD800, 0xDC00, 0xD800, 0 };
+ // broken surrogate pairs
+ ushort utf16[] = { 0xDC00, 0xD800, 'x', 0xD800, 0 };
string = QString::fromUtf16(utf16);
qDebug() << string;
- QCOMPARE(s_msg, QString("\"\\uDC00\\U00010000x\\U00010000\\uD800\""));
+ QCOMPARE(s_msg, QString("\"\\uDC00\\uD800x\\uD800\""));
}
void tst_QDebug::qDebugQStringRef() const