Skip to content

Instantly share code, notes, and snippets.

@pcolby
Created July 1, 2015 06:01
Show Gist options
  • Save pcolby/39d8d35ce3abb7d3b6e9 to your computer and use it in GitHub Desktop.
Save pcolby/39d8d35ce3abb7d3b6e9 to your computer and use it in GitHub Desktop.
A printable variant for QtTest
// Usage: QCOMPARE(PrintableVariant(v1), PrintableVariant(v2));
// Note, QTest will still limit output to 1024 chars in QTestResult::compare
class PrintableVariant : public QVariant {
public: PrintableVariant(const QVariant &other) : QVariant(other) { }
};
namespace QTest {
template<> char *toString(const PrintableVariant &variant){
QString string;
QDebug debug(&string);
debug << variant;
return qstrdup(string.toLocal8Bit());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment