Testlib: Explicitly cast messages to const char *
Macro parameters should always be enclosed in braces when used. Plain C strings passed in parantheses are interpreted as const char[], at least by clang-tidy. Implicitly decaying arrays into pointers should be avoided and clang-tidy warns about this. Avoid both problems by always static casting all messages to const char *. Change-Id: I2be668169bec2823f69af3aa75086a31b0b31938 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>bb10
parent
84ff636ecf
commit
c7453cf676
|
|
@ -67,17 +67,17 @@ do {\
|
|||
|
||||
#define QFAIL(message) \
|
||||
do {\
|
||||
QTest::qFail(message, __FILE__, __LINE__);\
|
||||
QTest::qFail(static_cast<const char *>(message), __FILE__, __LINE__);\
|
||||
return;\
|
||||
} while (false)
|
||||
|
||||
#define QVERIFY2(statement, description) \
|
||||
do {\
|
||||
if (statement) {\
|
||||
if (!QTest::qVerify(true, #statement, (description), __FILE__, __LINE__))\
|
||||
if (!QTest::qVerify(true, #statement, static_cast<const char *>(description), __FILE__, __LINE__))\
|
||||
return;\
|
||||
} else {\
|
||||
if (!QTest::qVerify(false, #statement, (description), __FILE__, __LINE__))\
|
||||
if (!QTest::qVerify(false, #statement, static_cast<const char *>(description), __FILE__, __LINE__))\
|
||||
return;\
|
||||
}\
|
||||
} while (false)
|
||||
|
|
@ -184,7 +184,7 @@ do { \
|
|||
|
||||
#define QSKIP_INTERNAL(statement) \
|
||||
do {\
|
||||
QTest::qSkip(statement, __FILE__, __LINE__);\
|
||||
QTest::qSkip(static_cast<const char *>(statement), __FILE__, __LINE__);\
|
||||
return;\
|
||||
} while (false)
|
||||
|
||||
|
|
@ -200,7 +200,7 @@ do {\
|
|||
|
||||
#define QEXPECT_FAIL(dataIndex, comment, mode)\
|
||||
do {\
|
||||
if (!QTest::qExpectFail(dataIndex, comment, QTest::mode, __FILE__, __LINE__))\
|
||||
if (!QTest::qExpectFail(dataIndex, static_cast<const char *>(comment), QTest::mode, __FILE__, __LINE__))\
|
||||
return;\
|
||||
} while (false)
|
||||
|
||||
|
|
@ -217,7 +217,7 @@ do {\
|
|||
} while (false)
|
||||
|
||||
#define QWARN(msg)\
|
||||
QTest::qWarn(msg, __FILE__, __LINE__)
|
||||
QTest::qWarn(static_cast<const char *>(msg), __FILE__, __LINE__)
|
||||
|
||||
#ifdef QT_TESTCASE_BUILDDIR
|
||||
# define QFINDTESTDATA(basepath)\
|
||||
|
|
|
|||
Loading…
Reference in New Issue