summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@digia.com>2014-02-13 14:44:38 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-13 13:26:02 +0100
commitf6d0c67d30ef1c22b086641e8d1288e1baaa1663 (patch)
treefae2d2285e9dbdc3163a59e388cccda07f07578f /tests/auto
parent1f4cda9a70dd8b1fbabe716de26cace85f3aef41 (diff)
QDebug: Allow text stream formatting for 64 bit numbers
Use the QTextStream stream operator for formatting 64 bit numbers, just like we do for other numbers, too. This ensures all numbers in a QDebug stream e.g. respect the hex and showbase modifiers. The original reason for formatting qin64, quint64 with QString::number is unclear (pre-dates the original qt4 git import). Maybe QTextStream did lack proper support for 64 bit numbers back then. Task-number: QTBUG-36841 Change-Id: I049516c2a8394c9c1a708f86c3d950418a20a957 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/io/qdebug/tst_qdebug.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
index 29c7e6a81e..80144dba20 100644
--- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
+++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
@@ -57,6 +57,7 @@ private slots:
void veryLongWarningMessage() const;
void qDebugQStringRef() const;
void qDebugQLatin1String() const;
+ void textStreamModifiers() const;
void defaultMessagehandler() const;
};
@@ -280,6 +281,18 @@ void tst_QDebug::qDebugQLatin1String() const
QCOMPARE(QString::fromLatin1(s_function), function);
}
+void tst_QDebug::textStreamModifiers() const
+{
+ MessageHandlerSetter mhs(myMessageHandler);
+ { qDebug() << hex << short(0xf) << int(0xf) << unsigned(0xf) << long(0xf) << qint64(0xf) << quint64(0xf); }
+ QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO;
+ QCOMPARE(s_msgType, QtDebugMsg);
+ QCOMPARE(s_msg, QString::fromLatin1("f f f f f f"));
+ QCOMPARE(QString::fromLatin1(s_file), file);
+ QCOMPARE(s_line, line);
+ QCOMPARE(QString::fromLatin1(s_function), function);
+}
+
void tst_QDebug::defaultMessagehandler() const
{
MessageHandlerSetter mhs(0);