summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtestresult_p.h
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2022-05-19 13:48:45 +0200
committerIvan Solovev <ivan.solovev@qt.io>2022-06-03 22:37:50 +0200
commit343e0ff485de36e27c0a62781dc512a4bda22fce (patch)
tree800a71669093a5d9bcd60048f9be9f8badbe0367 /src/testlib/qtestresult_p.h
parent9327d1aaf79d4214db78ec86b8b6df7738bd1875 (diff)
Add QCOMPARE_{EQ,NE,LT,LE,GT,GE}()
[ChangeLog][QTestLib] Add QCOMPARE_{EQ,NE,LT,LE,GT,GE}() macros. These new macros behave similarly to QVERIFY(a op b), where 'op' is ==, !=, <, <=, >, >= respectively, but print a formatted error message with argument values in case of failure. The formatting is done lazily, which means that the strings will be generated only when the comparison fails. Also add a new test for tst_selftest and generate expected output for it. Fixes: QTBUG-98873 Task-number: QTBUG-98874 Change-Id: Ic8074798901d7a469b1f58d5cd28bbf49a3da1db Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/testlib/qtestresult_p.h')
-rw-r--r--src/testlib/qtestresult_p.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/testlib/qtestresult_p.h b/src/testlib/qtestresult_p.h
index fac81b5e80..fa4e117fb3 100644
--- a/src/testlib/qtestresult_p.h
+++ b/src/testlib/qtestresult_p.h
@@ -17,6 +17,7 @@
#include <QtTest/qttestglobal.h>
#include <QtCore/qstringfwd.h>
+#include <QtCore/qxpfunctional.h>
#include <QtCore/private/qglobal_p.h>
QT_BEGIN_NAMESPACE
@@ -95,6 +96,11 @@ public:
static void setCurrentAppName(const char *appName);
static const char *currentAppName();
+ static bool reportResult(bool success, qxp::function_ref<const char *()> lhs,
+ qxp::function_ref<const char *()> rhs,
+ const char *lhsExpr, const char *rhsExpr,
+ QTest::ComparisonOperation op, const char *file, int line);
+
private:
Q_DISABLE_COPY(QTestResult)
};