Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qcomparisontesthelper_p.h File Reference

(15eb9dccae8264c97c1fc242f999003f3bbff9ff)

#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)
 
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 */
@ Left
@ Right

Definition at line 132 of file qcomparisontesthelper_p.h.

Referenced by QTestPrivate::testAllComparisonOperators(), and QTestPrivate::testEqualityOperators().

◆ 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 141 of file qcomparisontesthelper_p.h.

Referenced by QTestPrivate::testAllComparisonOperators(), and QTestPrivate::testEqualityOperators().

◆ CHECK_SINGLE_OPERATOR

#define CHECK_SINGLE_OPERATOR ( Left,
Right,
Op,
Result )
Value:
do { \
constexpr bool qtest_op_check_isImplNoexcept \
= noexcept(std::declval<Left>() Op std::declval<Right>()); \
if constexpr (!qtest_op_check_isImplNoexcept) { \
QEXPECT_FAIL("", QByteArray("(" + formatTypeWithCRef<Left>() \
+ " " #Op " " + formatTypeWithCRef<Right>() \
+ ") is not noexcept").constData(), \
Continue); \
/* Ideally, operators should be noexcept, so warn if they are not. */ \
/* Do not make it a hard error, because the fix is not always trivial. */ \
QVERIFY(qtest_op_check_isImplNoexcept); \
} \
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 */
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
if(qFloatDistance(a, b)<(1<< 7))
[0]

Definition at line 66 of file qcomparisontesthelper_p.h.

Referenced by QTestPrivate::testAllComparisonOperatorsCompile(), and QTestPrivate::testEqualityOperatorsCompile().

◆ 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.

Referenced by QTestPrivate::testAllComparisonOperatorsCompile(), and QTestPrivate::testEqualityOperatorsCompile().

◆ 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 { \
auto report = qScopeGuard([] { \
qDebug("testEqualityOperators(" #Left ", " #Right ", " #Expected ") " \
"failed in " __FILE__ " on line %d", __LINE__); \
}); \
QTestPrivate::testEqualityOperators(Left, Right, Expected); \
return; \
report.dismiss(); \
} 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 339 of file qcomparisontesthelper_p.h.