aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/shared.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/shared.h')
-rw-r--r--tests/auto/shared.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/auto/shared.h b/tests/auto/shared.h
index b0ce6f942..f16ca4bde 100644
--- a/tests/auto/shared.h
+++ b/tests/auto/shared.h
@@ -44,6 +44,18 @@
#include <memory>
+#define REPLACE_IN_FILE(filePath, oldContent, newContent) \
+ do { \
+ QFile f((filePath)); \
+ QVERIFY2(f.open(QIODevice::ReadWrite), qPrintable(f.errorString())); \
+ QByteArray content = f.readAll(); \
+ const QByteArray savedContent = content; \
+ content.replace((oldContent), (newContent)); \
+ QVERIFY(content != savedContent); \
+ f.resize(0); \
+ f.write(content); \
+ } while (false)
+
inline int testTimeoutInMsecs()
{
bool ok;