Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qcomparisontesthelper_p.h File Reference

(4a4c4252919d4894c7e5c6f2e636dda5dc1b1d0d)

#include <QtCore/q20type_traits.h>
#include <QtCore/qxptype_traits.h>
#include <QtTest/qtest.h>
+ Include dependency graph for qcomparisontesthelper_p.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  QTestPrivate
 

Macros

#define FOR_EACH_CREF(Func, Left, Right, Op, Result)
 
#define CHECK_SINGLE_OPERATOR(Left, Right, Op, Result)
 
#define CHECK_RUNTIME_CREF(Func, Left, Right, Op, Expected)
 
#define CHECK_RUNTIME_LR(Left, Right, Op, Expected)
 
#define QT_TEST_EQUALITY_OPS(Left, Right, Expected)
 
#define QT_TEST_ALL_COMPARISON_OPS(Left, Right, Expected)
 

Functions

QByteArray QTestPrivate::formatTypeWithCRefImpl (QMetaType type, bool isConst, bool isRef, bool isRvalueRef)
 
template<typename T>
QByteArray QTestPrivate::formatTypeWithCRef ()
 
template<typename LeftType, typename RightType = LeftType>
void QTestPrivate::testEqualityOperatorsCompile ()
 
template<typename LeftType, typename RightType = LeftType>
void QTestPrivate::testAllComparisonOperatorsCompile ()
 
template<typename LeftType, typename RightType>
void QTestPrivate::testEqualityOperators (LeftType lhs, RightType rhs, bool expectedEqual, const char *lhsExpr, const char *rhsExpr, const char *expected, const char *file, int line)
 
template<typename LeftType, typename RightType, typename OrderingType>
void QTestPrivate::testAllComparisonOperators (LeftType lhs, RightType rhs, OrderingType expectedOrdering)
 

Macro Definition Documentation

◆ CHECK_RUNTIME_CREF

#define CHECK_RUNTIME_CREF ( Func,
Left,
Right,
Op,
Expected )
Value:
do { \
Func(Left, Right, Op, Expected); \
Func(std::as_const(Left), Right, Op, Expected); \
Func(Left, std::as_const(Right), Op, Expected); \
Func(std::as_const(Left), std::as_const(Right), Op, Expected); \
} while (false) \
/* END */
@ Right
@ Left

Definition at line 121 of file qcomparisontesthelper_p.h.

◆ CHECK_RUNTIME_LR

#define CHECK_RUNTIME_LR ( Left,
Right,
Op,
Expected )
Value:
do { \
QCOMPARE_EQ(Left Op Right, Expected); \
QCOMPARE_EQ(std::move(Left) Op Right, Expected); \
QCOMPARE_EQ(Left Op std::move(Right), Expected); \
QCOMPARE_EQ(std::move(Left) Op std::move(Right), Expected); \
} while (false) \
/* END */

Definition at line 130 of file qcomparisontesthelper_p.h.

◆ CHECK_SINGLE_OPERATOR

#define CHECK_SINGLE_OPERATOR ( Left,
Right,
Op,
Result )
Value:
do { \
static_assert(std::is_convertible_v<decltype( \
std::declval<Left>() Op std::declval<Right>()), Result>); \
if constexpr (!std::is_same_v<Left, Right>) { \
static_assert(std::is_convertible_v<decltype( \
std::declval<Right>() Op std::declval<Left>()), Result>); \
} \
} while (false); \
/* END */

Definition at line 66 of file qcomparisontesthelper_p.h.

◆ FOR_EACH_CREF

#define FOR_EACH_CREF ( Func,
Left,
Right,
Op,
Result )
Value:
Func(Left &, Right &, Op, Result) \
Func(Left &, Right const &, Op, Result) \
Func(Left &, Right &&, Op, Result) \
Func(Left &, Right const &&, Op, Result) \
Func(Left const &, Right &, Op, Result) \
Func(Left const &, Right const &, Op, Result) \
Func(Left const &, Right &&, Op, Result) \
Func(Left const &, Right const &&, Op, Result) \
Func(Left &&, Right &, Op, Result) \
Func(Left &&, Right const &, Op, Result) \
Func(Left &&, Right &&, Op, Result) \
Func(Left &&, Right const &&, Op, Result) \
Func(Left const &&, Right &, Op, Result) \
Func(Left const &&, Right const &, Op, Result) \
Func(Left const &&, Right &&, Op, Result) \
Func(Left const &&, Right const &&, Op, Result) \
/* END */

Definition at line 47 of file qcomparisontesthelper_p.h.

◆ QT_TEST_ALL_COMPARISON_OPS

#define QT_TEST_ALL_COMPARISON_OPS ( Left,
Right,
Expected )
Value:
do { \
auto report = qScopeGuard([] { \
qDebug("testAllComparisonOperators(" #Left ", " #Right ", " #Expected ") " \
"failed in " __FILE__ " on line %d", __LINE__); \
}); \
QTestPrivate::testAllComparisonOperators(Left, Right, Expected); \
return; \
report.dismiss(); \
} while (false)
Q_TESTLIB_EXPORT bool currentTestFailed()
Returns true if the current test function has failed, otherwise false.
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]
Definition qscopeguard.h:60

A helper macro that calls QTestPrivate::testAllComparisonOperators(), checks the test's state after the function is executed, and generates a meaningful debug message with the original file and line numbers if the test has failed.

Definition at line 359 of file qcomparisontesthelper_p.h.

◆ QT_TEST_EQUALITY_OPS

#define QT_TEST_EQUALITY_OPS ( Left,
Right,
Expected )
Value:
do { \
QTestPrivate::testEqualityOperators(Left, Right, Expected, #Left, #Right, #Expected, \
__FILE__, __LINE__); \
return; \
} while (false)

A helper macro that calls QTestPrivate::testEqualityOperators(), checks the test's state after the function is executed, and generates a meaningful debug message with the original file and line numbers if the test has failed.

Definition at line 343 of file qcomparisontesthelper_p.h.