diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-01-06 20:59:16 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-01-08 00:44:16 +0100 |
commit | bac0796308e0cd76519ac76dfe06e7a749c20c0a (patch) | |
tree | de6b912528848a23f934093a6070812124cea466 /src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp | |
parent | 4b08561bb07926eb6426376bdef6bf9e0f99bec6 (diff) |
QTest: update docs for toString()
Following c61f8df4047a616ffcb5e775fa8e5981b13e193f, we now prefer overloading
toString() in the type's namespace over specializing the primary template.
Let the docs reflect that and add an example. Also suggest to delegate the messy
raw char pointer handling to the existing toString(QString)/toString(QBA)
overloads.
Change-Id: Id76181faba86aea52588611ea64ea9b95371a733
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp')
-rw-r--r-- | src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp b/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp index 7bcae3bf74..42dd082214 100644 --- a/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp +++ b/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp @@ -153,6 +153,19 @@ namespace QTest { } //! [16] +//! [toString-overload] +namespace MyNamespace { + char *toString(const MyPoint &point) + { + // bring QTest::toString overloads into scope: + using QTest::toString; + // delegate char* handling to QTest::toString(QByteArray): + return toString("MyPoint(" + + QByteArray::number(point.x()) + ", " + + QByteArray::number(point.y()) + ')'); + } +} +//! [toString-overload] //! [17] int i = 0; |