diff options
author | Karsten Heimrich <karsten.heimrich@qt.io> | 2020-11-03 15:03:57 +0100 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@qt.io> | 2020-11-07 09:35:11 +0100 |
commit | e9b92c926d56261cb0c78b5413b1132200efc4a8 (patch) | |
tree | 3695a374d56e6227952ffc4d5b9c84aec3762e99 /tests/auto/corelib/io/qdebug/tst_qdebug.cpp | |
parent | 7cad91a7df03d0683c81519ae6839c5f546cfceb (diff) |
QDebug: add op<<(QUtf8StringView)
[ChangeLog][QtCore][QDebug] Added streaming of QUtf8StringViews.
Task-number: QTBUG-88029
Change-Id: Ifcb001cfebddd79ce1cdbfef5bcc19f7c56679ec
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/io/qdebug/tst_qdebug.cpp')
-rw-r--r-- | tests/auto/corelib/io/qdebug/tst_qdebug.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp index d68cbc5e25..6acc80bdc4 100644 --- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp +++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp @@ -73,6 +73,7 @@ private slots: void qDebugQChar() const; void qDebugQString() const; void qDebugQStringView() const; + void qDebugQUtf8StringView() const; void qDebugQLatin1String() const; void qDebugQByteArray() const; void qDebugQByteArrayView() const; @@ -556,6 +557,46 @@ void tst_QDebug::qDebugQStringView() const } } +void tst_QDebug::qDebugQUtf8StringView() const +{ + /* Use a utf8 string. */ + { + QLatin1String file, function; + int line = 0; + const QUtf8StringView inView = u8"\U0001F609 is ;-)"; + + MessageHandlerSetter mhs(myMessageHandler); + { qDebug() << inView; } +#ifndef QT_NO_MESSAGELOGCONTEXT + file = QLatin1String(__FILE__); line = __LINE__ - 2; function = QLatin1String(Q_FUNC_INFO); +#endif + QCOMPARE(s_msgType, QtDebugMsg); + QCOMPARE(s_msg, QString::fromUtf8("\"\\xF0\\x9F\\x98\\x89 is ;-)\"")); + QCOMPARE(QLatin1String(s_file), file); + QCOMPARE(s_line, line); + QCOMPARE(QLatin1String(s_function), function); + } + + /* Use a null QUtf8StringView. */ + { + QString file, function; + int line = 0; + + const QUtf8StringView inView; + + MessageHandlerSetter mhs(myMessageHandler); + { qDebug() << inView; } +#ifndef QT_NO_MESSAGELOGCONTEXT + file = __FILE__; line = __LINE__ - 2; function = Q_FUNC_INFO; +#endif + QCOMPARE(s_msgType, QtDebugMsg); + QCOMPARE(s_msg, QLatin1String("\"\"")); + QCOMPARE(QLatin1String(s_file), file); + QCOMPARE(s_line, line); + QCOMPARE(QLatin1String(s_function), function); + } +} + void tst_QDebug::qDebugQLatin1String() const { QString file, function; |