diff options
author | David Faure <faure@kde.org> | 2012-07-27 13:53:16 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-27 22:05:26 +0200 |
commit | 8cf7cf0cb96188b42e10958711f8c3aa016396c3 (patch) | |
tree | e8d30c34775aa5a4dc320a2c2ac535e2d6933beb /tests | |
parent | 54e3ce17053619a323cf5ba436773101da6fda23 (diff) |
QDebug: Add getter/setter for auto-insert-spaces.
This is useful for inserting a string without space-handling, given that
dbg.nospace() followed by dbg.space() inserts a space.
It's also useful for QDebug operators for custom types, so that they
can disable space handling and then restore to whatever it was before
(rather than forcing it to space() mode).
Change-Id: I9d72e9ffbcbc581ed093168752c29af924405b33
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/io/qdebug/tst_qdebug.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp index 035c781e4a..3e3204a162 100644 --- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp +++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp @@ -52,6 +52,7 @@ private slots: void warningWithoutDebug() const; void criticalWithoutDebug() const; void debugWithBool() const; + void debugNoSpaces() const; void veryLongWarningMessage() const; void qDebugQStringRef() const; void qDebugQLatin1String() const; @@ -149,6 +150,26 @@ void tst_QDebug::debugWithBool() const QCOMPARE(QString::fromLatin1(s_function), function); } +void tst_QDebug::debugNoSpaces() const +{ + MessageHandlerSetter mhs(myMessageHandler); + { + QDebug d = qDebug(); + QVERIFY(d.autoInsertSpaces()); + d.setAutoInsertSpaces(false); + QVERIFY(!d.autoInsertSpaces()); + d << " "; + d.setAutoInsertSpaces(true); + QVERIFY(d.autoInsertSpaces()); + d << "foo"; + d.nospace(); + d << "key=" << "value"; + d.space(); + d << 1 << 2; + } + QCOMPARE(s_msg, QString::fromLatin1(" foo key=value 1 2 ")); +} + void tst_QDebug::veryLongWarningMessage() const { MessageHandlerSetter mhs(myMessageHandler); |