QTestlib: Fix formatting of pointers in QCOMPARE

After 1ed8a7bff5,
volatile needs to be specified for toString(), else it is not
used by compare_ptr_helper(). Add an overload.

Pick-to: 6.1 5.15
Change-Id: I3c335f324df346233623272d1014c8360ca33160
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Friedemann Kleint 2021-05-21 09:53:40 +02:00
parent 895edcd7cd
commit 6fff7bb269
2 changed files with 7 additions and 1 deletions

View File

@ -2810,6 +2810,11 @@ char *QTest::toString(const char *str)
/*! \internal
*/
char *QTest::toString(const volatile void *p) // Use volatile to match compare_ptr_helper()
{
return QTest::toString(const_cast<const void *>(p));
}
char *QTest::toString(const void *p)
{
char *msg = new char[128];

View File

@ -295,7 +295,8 @@ namespace QTest
Q_TESTLIB_EXPORT char *toPrettyCString(const char *unicode, int length);
Q_TESTLIB_EXPORT char *toPrettyUnicode(QStringView string);
Q_TESTLIB_EXPORT char *toString(const char *);
Q_TESTLIB_EXPORT char *toString(const void *);
Q_TESTLIB_EXPORT char *toString(const volatile void *);
Q_TESTLIB_EXPORT char *toString(const void *); // ### FIXME: Qt 7: Remove
Q_TESTLIB_EXPORT void qInit(QObject *testObject, int argc = 0, char **argv = nullptr);
Q_TESTLIB_EXPORT int qRun();