summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtestcase.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2021-06-14 15:34:40 +0200
committerMarc Mutz <marc.mutz@kdab.com>2021-06-15 01:36:56 +0200
commit66d080af31f1409e2011661db9024c1d81ceec87 (patch)
tree86f8cb5211856c52ebce5ead28b30404d54ef085 /src/testlib/qtestcase.cpp
parentfb3f90398001b2f0acbf2a12ec22cc2708a2d29b (diff)
QtTest: move QTRY_X error message formatting out-of-line
Clazy warns about the fromUtf8() call with a constant argument, for every use of the macro, so hide the stuff behind a compiler firewall. Also fix the format injection error by using QLatin1String::arg() instead of QString::arg() chaining. Change-Id: I4bb4d4af56443540efc0c38c75819aa152a441fc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/testlib/qtestcase.cpp')
-rw-r--r--src/testlib/qtestcase.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index b1e6401b0f..c08ad58d75 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -285,6 +285,14 @@ namespace QTestPrivate
namespace QTest
{
+
+QString Internal::formatTryTimeoutDebugMessage(q_no_char8_t::QUtf8StringView expr, int timeout, int actual)
+{
+ return QLatin1String("QTestLib: This test case check (\"%1\") failed because the requested timeout (%2 ms) was too short, %3 ms would have been sufficient this time.")
+ // ### Qt 7: remove the toString() (or earlier, when arg() can handle QUtf8StringView), passing the view directly
+ .arg(expr.toString(), QString::number(timeout), QString::number(actual));
+}
+
extern Q_TESTLIB_EXPORT int lastMouseTimestamp;
class WatchDog;