diff options
author | Ivan Solovev <[email protected]> | 2022-05-19 13:48:45 +0200 |
---|---|---|
committer | Ivan Solovev <[email protected]> | 2022-06-03 22:37:50 +0200 |
commit | 343e0ff485de36e27c0a62781dc512a4bda22fce (patch) | |
tree | 800a71669093a5d9bcd60048f9be9f8badbe0367 /src/testlib/qtestcase.cpp | |
parent | 9327d1aaf79d4214db78ec86b8b6df7738bd1875 (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.cpp | 8 |
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 { |