QDebug: normalize std::pair output separator

All other container stream operators use COMMA SP, while std::pair
used COMMA w/o SP.

Add the space to make the output a bit more readable, and for
consistency.

[ChangeLog][QtCore][QDebug] The output of a streamed std::pair has now
a space after the separating comma, like for other containers.

Change-Id: I01f83509038566cb9369d7ec743751b2ccc0903a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Marc Mutz 2024-10-21 14:42:06 +02:00
parent defd1549de
commit c1cb30f85b
2 changed files with 3 additions and 3 deletions

View File

@ -436,7 +436,7 @@ template <class T1, class T2>
inline QDebugIfHasDebugStream<T1, T2> operator<<(QDebug debug, const std::pair<T1, T2> &pair)
{
const QDebugStateSaver saver(debug);
debug.nospace() << "std::pair(" << pair.first << ',' << pair.second << ')';
debug.nospace() << "std::pair(" << pair.first << ", " << pair.second << ')';
return debug;
}

View File

@ -704,7 +704,7 @@ void tst_QDebug::qDebugStdPair() const
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_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);
@ -712,7 +712,7 @@ void tst_QDebug::qDebugStdPair() const
/* 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);
QCOMPARE(s_msg, R"(std::pair(std::pair(std::pair(4.2, 42), .42), "42"))"_L1);
}
void tst_QDebug::qDebugStdString() const