summaryrefslogtreecommitdiff
path: root/tests/common/printQtTypes.cpp
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2021-07-14 11:49:10 +1200
committerJedidiah Barber <contact@jedbarber.id.au>2021-07-14 11:49:10 +1200
commitd24f813f3f2a05c112e803e4256b53535895fc98 (patch)
tree601e6ae9a1cd44bcfdcf91739a5ca36aedd827c9 /tests/common/printQtTypes.cpp
Initial mirror commitHEADmaster
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 << "\"";
+}