summaryrefslogtreecommitdiff
path: root/tests/common/printQtTypes.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/common/printQtTypes.cpp')
-rw-r--r--tests/common/printQtTypes.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/common/printQtTypes.cpp b/tests/common/printQtTypes.cpp
new file mode 100644
index 0000000..72975b7
--- /dev/null
+++ b/tests/common/printQtTypes.cpp
@@ -0,0 +1,31 @@
+#include "printQtTypes.h"
+
+void PrintTo(const QString& str, ::std::ostream* os)
+{
+ *os << "\"" << str.toStdString() << "\"";
+}
+
+void PrintTo(const QStringList& list, ::std::ostream* os)
+{
+ *os << "(" << list.join(", ").toStdString() << ")";
+}
+
+void PrintTo(const QDateTime& time, ::std::ostream* os)
+{
+ *os << time.toString("yyyy-MM-dd HH:mm:ss").toStdString();
+}
+
+void PrintTo(const QByteArray& array, ::std::ostream* os)
+{
+ *os << "\"";
+ const char* hex = array.toHex().constData();
+ for(int i = 0; i < array.size(); i++)
+ {
+ unsigned char ch = array.constData()[i];
+ if(ch >= 32 && ch <= 126)
+ *os << ch;
+ else
+ *os << "\\x" << hex[i * 2] << hex[i * 2 + 1] << " ";
+ }
+ *os << "\"";
+}