From 343e0ff485de36e27c0a62781dc512a4bda22fce Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Thu, 19 May 2022 13:48:45 +0200 Subject: Add QCOMPARE_{EQ,NE,LT,LE,GT,GE}() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [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 Reviewed-by: Thiago Macieira Reviewed-by: Tor Arne Vestbø Reviewed-by: Qt CI Bot Reviewed-by: Edward Welbourne --- src/testlib/qtestresult_p.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/testlib/qtestresult_p.h') 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 #include +#include #include 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 lhs, + qxp::function_ref rhs, + const char *lhsExpr, const char *rhsExpr, + QTest::ComparisonOperation op, const char *file, int line); + private: Q_DISABLE_COPY(QTestResult) }; -- cgit v1.2.3