summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtestcase.cpp
diff options
context:
space:
mode:
authorIvan Solovev <[email protected]>2022-05-19 13:48:45 +0200
committerIvan Solovev <[email protected]>2022-06-03 22:37:50 +0200
commit343e0ff485de36e27c0a62781dc512a4bda22fce (patch)
tree800a71669093a5d9bcd60048f9be9f8badbe0367 /src/testlib/qtestcase.cpp
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 <[email protected]> Reviewed-by: Thiago Macieira <[email protected]> Reviewed-by: Tor Arne Vestbø <[email protected]> Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Edward Welbourne <[email protected]>
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 7760ab8f8c7..919447cce30 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -1728,6 +1728,14 @@ void TestMethods::invokeTests(QObject *testObject) const
QSignalDumper::endDump();
}
+bool reportResult(bool success, qxp::function_ref<const char *()> lhs,
+ qxp::function_ref<const char *()> rhs,
+ const char *lhsExpr, const char *rhsExpr,
+ ComparisonOperation op, const char *file, int line)
+{
+ return QTestResult::reportResult(success, lhs, rhs, lhsExpr, rhsExpr, op, file, line);
+}
+
} // namespace QTest
namespace {