From 04b180f7f25d73d002df31085cf1c352e075d4e5 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Thu, 7 Dec 2017 09:46:30 +0100 Subject: Improve std::tuple handling in tests Currently when doing comparison with std::tuple the fallback toString method is called which returns a Q_NULLPTR thus not allowing proper diagnostic of the values that triggered an error. This patch adds support for std::tuple to improve the tests output readability. [ChangeLog][QtTest][QCOMPARE] Now outputs contents of std::tuple on failure. Change-Id: I046a55e2ce44c3f7728d51e4745120d38aa5e007 Reviewed-by: Thiago Macieira --- src/testlib/qtestcase.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/testlib/qtestcase.h') diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index 4bf816a850..f6891dc941 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -283,6 +283,9 @@ namespace QTest template inline char *toString(const std::pair &pair); + template + inline char *toString(const std::tuple &tuple); + Q_TESTLIB_EXPORT char *toHexRepresentation(const char *ba, int length); Q_TESTLIB_EXPORT char *toPrettyCString(const char *unicode, int length); Q_TESTLIB_EXPORT char *toPrettyUnicode(QStringView string); @@ -388,6 +391,8 @@ namespace QTest Q_TESTLIB_EXPORT bool compare_string_helper(const char *t1, const char *t2, const char *actual, const char *expected, const char *file, int line); + Q_TESTLIB_EXPORT char *formatString(const char *prefix, const char *suffix, size_t numArguments, ...); + #ifndef Q_QDOC QTEST_COMPARE_DECL(short) QTEST_COMPARE_DECL(ushort) -- cgit v1.2.3