From c1cb30f85b3e1fe326f804e120bc8eb14195f717 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 21 Oct 2024 14:42:06 +0200 Subject: [PATCH] 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 --- src/corelib/io/qdebug.h | 2 +- tests/auto/corelib/io/qdebug/tst_qdebug.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index c4be5955c8e..55be6d13a48 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -436,7 +436,7 @@ template inline QDebugIfHasDebugStream operator<<(QDebug debug, const std::pair &pair) { const QDebugStateSaver saver(debug); - debug.nospace() << "std::pair(" << pair.first << ',' << pair.second << ')'; + debug.nospace() << "std::pair(" << pair.first << ", " << pair.second << ')'; return debug; } diff --git a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp index 1e76340b05a..107bf1f2c98 100644 --- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp +++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp @@ -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