From d24f813f3f2a05c112e803e4256b53535895fc98 Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Wed, 14 Jul 2021 11:49:10 +1200 Subject: Initial mirror commit --- tests/common/printQtTypes.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/common/printQtTypes.cpp (limited to 'tests/common/printQtTypes.cpp') 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 << "\""; +} -- cgit