tst_QDebug: add missing test for std::pair streaming

tst_QPair also doesn't have it.

Pick-to: 6.5 6.2
Change-Id: I7391203a9dcb2d937487ee2f3ba1b6ed21d700db
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 9b0970ad820c084b0fe73bcbbc72b44f04cae3dd)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2024-10-21 14:31:52 +02:00 committed by Qt Cherry-pick Bot
parent 7c54868d8c
commit 5c4a0a5b26

View File

@ -74,6 +74,7 @@ private slots:
void qDebugQStringView() const;
void qDebugQUtf8StringView() const;
void qDebugQLatin1String() const;
void qDebugStdPair() const;
void qDebugStdString() const;
void qDebugStdStringView() const;
void qDebugStdWString() const;
@ -678,6 +679,31 @@ void tst_QDebug::qDebugQLatin1String() const
QCOMPARE(s_msg, QString("\"\\nSm\\u00F8rg\\u00E5sbord\\\\\""));
}
void tst_QDebug::qDebugStdPair() const
{
QByteArray file, function;
int line = 0;
MessageHandlerSetter mhs(myMessageHandler);
{
QDebug d = qDebug();
d << std::pair(42, u"foo"_s) << std::pair(u"barbaz"_s, 4.2);
d.nospace().noquote() << std::pair(u"baz"_s, -42);
}
#ifndef QT_NO_MESSAGELOGCONTEXT
file = __FILE__; line = __LINE__ - 5; function = Q_FUNC_INFO;
#endif
QCOMPARE(s_msgType, QtDebugMsg);
QCOMPARE(s_msg, R"(std::pair(42,"foo") std::pair("barbaz",4.2) std::pair(baz,-42))"_L1);
QCOMPARE(s_file, file);
QCOMPARE(s_line, line);
QCOMPARE(s_function, function);
/* simpler tests from now on */
// nested:
qDebug() << std::pair(std::pair(std::pair(4.2, 42), ".42"), u"42"_s);
QCOMPARE(s_msg, R"(std::pair(std::pair(std::pair(4.2,42),.42),"42"))"_L1);
}
void tst_QDebug::qDebugStdString() const
{
QString file, function;