From 396eba363b22c2c1c939c60ffa1e14fe2f4506fa Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 23 Nov 2017 16:22:55 +0100 Subject: Check for errors --- examples/imapresource/tests/imapmailsynctest.cpp | 4 ++-- tests/testutils.h | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/imapresource/tests/imapmailsynctest.cpp b/examples/imapresource/tests/imapmailsynctest.cpp index f20a77e..23bb4e5 100644 --- a/examples/imapresource/tests/imapmailsynctest.cpp +++ b/examples/imapresource/tests/imapmailsynctest.cpp @@ -95,8 +95,8 @@ protected: QByteArray createMessage(const QStringList &folderPath, const QByteArray &message) Q_DECL_OVERRIDE { Imap::ImapServerProxy imap("localhost", 993); - imap.login("doe", "doe").exec().waitForFinished(); - imap.append("INBOX." + folderPath.join('.'), message).exec().waitForFinished(); + VERIFYEXEC_RET(imap.login("doe", "doe"), {}); + VERIFYEXEC_RET(imap.append("INBOX." + folderPath.join('.'), message), {}); return "2:*"; } diff --git a/tests/testutils.h b/tests/testutils.h index f464e76..717f2ec 100644 --- a/tests/testutils.h +++ b/tests/testutils.h @@ -38,6 +38,14 @@ do {\ return;\ } while (0) +#define VERIFYEXEC_RET(statement, return) \ +do {\ + auto result = statement.exec(); \ + result.waitForFinished(); \ + if (!QTest::qVerify(!result.errorCode(), #statement, "", __FILE__, __LINE__))\ + return #return;\ +} while (0) + #define VERIFYEXEC_FAIL(statement) \ do {\ auto result = statement.exec(); \ -- cgit v1.2.3