summaryrefslogtreecommitdiffstats
path: root/src/testlib
diff options
context:
space:
mode:
Diffstat (limited to 'src/testlib')
-rw-r--r--src/testlib/qtest.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h
index 9d6f68d..8cdfab0 100644
--- a/src/testlib/qtest.h
+++ b/src/testlib/qtest.h
@@ -53,6 +53,7 @@
#include <QtCore/qstringlist.h>
#include <QtCore/qdatetime.h>
#include <QtCore/qobject.h>
+#include <QtCore/qvariant.h>
#include <QtCore/qurl.h>
#include <QtCore/qpoint.h>
@@ -146,6 +147,30 @@ template<> inline char *toString(const QUrl &uri)
return qstrdup(uri.toEncoded().constData());
}
+template<> inline char *toString(const QVariant &v)
+{
+ QByteArray vstring("QVariant(");
+ if (v.isValid()) {
+ QByteArray type(v.typeName());
+ if (type.isEmpty()) {
+ type = QByteArray::number(v.userType());
+ }
+ vstring.append(type);
+ if (!v.isNull()) {
+ vstring.append(',');
+ if (v.canConvert(QVariant::String)) {
+ vstring.append(qVariantValue<QString>(v).toLatin1());
+ }
+ else {
+ vstring.append("<value not representable as string>");
+ }
+ }
+ }
+ vstring.append(')');
+
+ return qstrdup(vstring.constData());
+}
+
#ifndef QTEST_NO_SPECIALIZATIONS
template<>
#endif