summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtest.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2017-04-21 12:13:21 +0200
committerMarc Mutz <marc.mutz@kdab.com>2017-04-24 19:35:11 +0000
commit09f6227653b192c1a062c52f41eb36c3ab35fc25 (patch)
tree5922de4622ddde5ff32b4078f0cadeec80e5cfd3 /src/testlib/qtest.h
parentff93eddfd5dc4bae0a037dfa6be27e8f6014f6ec (diff)
QtTest: add support for printing QStringViews
[ChangeLog][QtTest][QCOMPARE] Now supports printing QStringViews in case of test failures. Change-Id: I4dc2542cd1013fd63c094c249e721d7102387bde Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/testlib/qtest.h')
-rw-r--r--src/testlib/qtest.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h
index 30aadfba92..4abba93721 100644
--- a/src/testlib/qtest.h
+++ b/src/testlib/qtest.h
@@ -65,9 +65,14 @@ QT_BEGIN_NAMESPACE
namespace QTest
{
+template <> inline char *toString(const QStringView &str)
+{
+ return QTest::toPrettyUnicode(str);
+}
+
template<> inline char *toString(const QString &str)
{
- return QTest::toPrettyUnicode(reinterpret_cast<const ushort *>(str.constData()), str.length());
+ return toString(QStringView(str));
}
template<> inline char *toString(const QLatin1String &str)