summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtestresult.cpp
diff options
context:
space:
mode:
authorJason McDonald <jason.mcdonald@nokia.com>2012-03-08 11:20:41 +1000
committerQt by Nokia <qt-info@nokia.com>2012-03-08 07:30:36 +0100
commitd78fab531a34ee911e373eaef0fbf3626b74c07c (patch)
treece48900750ab1494c79446470be6f37ca94211d3 /src/testlib/qtestresult.cpp
parent48209e21ec088a481c310f8b4a755209c5de0b15 (diff)
testlib: Make QTestResult::verify() more robust.
The statementStr parameter should always be non-null, so assert if it is null. The description parameter can be null in some cases (particularly when the verify is successful, and thus no error description is going to be displayed), so tolerate this. Change-Id: I87b416d5f3b793bc608cd4aca14a4f7fe7527488 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'src/testlib/qtestresult.cpp')
-rw-r--r--src/testlib/qtestresult.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/testlib/qtestresult.cpp b/src/testlib/qtestresult.cpp
index 231fc8f3b1..cbededfee2 100644
--- a/src/testlib/qtestresult.cpp
+++ b/src/testlib/qtestresult.cpp
@@ -230,6 +230,8 @@ static bool checkStatement(bool statement, const char *msg, const char *file, in
bool QTestResult::verify(bool statement, const char *statementStr,
const char *description, const char *file, int line)
{
+ QTEST_ASSERT(statementStr);
+
char msg[1024];
if (QTestLog::verboseLevel() >= 2) {
@@ -240,7 +242,7 @@ bool QTestResult::verify(bool statement, const char *statementStr,
const char * format = QTest::expectFailMode
? "'%s' returned TRUE unexpectedly. (%s)"
: "'%s' returned FALSE. (%s)";
- qsnprintf(msg, 1024, format, statementStr, description);
+ qsnprintf(msg, 1024, format, statementStr, description ? description : "");
return checkStatement(statement, msg, file, line);
}