Created
July 1, 2015 06:01
-
-
Save pcolby/39d8d35ce3abb7d3b6e9 to your computer and use it in GitHub Desktop.
A printable variant for QtTest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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