diff options
Diffstat (limited to 'src/testlib/qtestlog.cpp')
-rw-r--r-- | src/testlib/qtestlog.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp index 0e67335222..b2efa1ac9c 100644 --- a/src/testlib/qtestlog.cpp +++ b/src/testlib/qtestlog.cpp @@ -111,11 +111,25 @@ namespace QTest { last->next = item; } + static bool stringsMatch(const QString &expected, const QString &actual) + { + if (expected == actual) + return true; + + // ignore an optional whitespace at the end of str + // (the space was added automatically by ~QDebug() until Qt 5.3, + // so autotests still might expect it) + if (expected.endsWith(QLatin1Char(' '))) + return actual == expected.leftRef(expected.length() - 1); + + return false; + } + inline bool matches(QtMsgType tp, const QString &message) const { return tp == type && (pattern.type() == QVariant::String ? - pattern.toString() == message : + stringsMatch(pattern.toString(), message) : pattern.toRegularExpression().match(message).hasMatch()); } |