diff options
author | Kai Koehne <kai.koehne@digia.com> | 2014-06-20 15:35:34 +0200 |
---|---|---|
committer | Kai Koehne <kai.koehne@digia.com> | 2014-07-30 16:27:33 +0200 |
commit | 5b0be0c2173e365b2484844ffd0b23ead5f9a48a (patch) | |
tree | 7fbd450869303c6e7b7ac3f91d75ce40c7049f9e /tests | |
parent | b795e8d7c2dbb04ed9bde4500a46511339b8df31 (diff) |
QDebug: Improve QDebug stream operator for QFlags
Use the built-in hex, showbase manipulator to format the number in
hex. Also, apply nospace() only once.
Change-Id: Id4b3d5f082ad13f52c8711408d7ec609bec3a621
Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/io/qdebug/tst_qdebug.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp index 767fde7f6c..764c928d76 100644 --- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp +++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp @@ -63,6 +63,7 @@ private slots: void qDebugQStringRef() const; void qDebugQLatin1String() const; void qDebugQByteArray() const; + void qDebugQFlags() const; void textStreamModifiers() const; void resetFormat() const; void defaultMessagehandler() const; @@ -395,6 +396,28 @@ void tst_QDebug::qDebugQByteArray() const QCOMPARE(QString::fromLatin1(s_function), function); } +enum TestEnum { + Flag1 = 0x1, + Flag2 = 0x10 +}; + +Q_DECLARE_FLAGS(TestFlags, TestEnum) + +void tst_QDebug::qDebugQFlags() const +{ + QFlags<TestEnum> flags(Flag1 | Flag2); + + MessageHandlerSetter mhs(myMessageHandler); + { qDebug() << flags; } + QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO; + QCOMPARE(s_msgType, QtDebugMsg); + QCOMPARE(s_msg, QString::fromLatin1("QFlags(0x1|0x10)")); + QCOMPARE(QString::fromLatin1(s_file), file); + QCOMPARE(s_line, line); + QCOMPARE(QString::fromLatin1(s_function), function); + +} + void tst_QDebug::textStreamModifiers() const { MessageHandlerSetter mhs(myMessageHandler); |