summaryrefslogtreecommitdiffstats
path: root/src/testlib
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-11-14 14:02:27 +0100
committerMarc Mutz <marc.mutz@qt.io>2023-11-21 11:46:27 +0100
commitbdd41f491c0f85ae0897a1c7372c5ecda62a5aab (patch)
tree6b5baa088a84cb92539846af611af70bfa8e363e /src/testlib
parent67072a70aff6688180bd3e008aef1f2a44e7469a (diff)
Rename Q*Ordering to Qt::*_ordering
Since we cannot re-use the pre-existing QPartialOrdering type due to binary-compatibility issues (it's not BC to std::partial_ordering), we're no longer bound to copy its API for consistency. So copy std::*_ordering type API for consistency instead, to ease porting for users that can already use C++20 and everyone else come Qt 7. This patch is another step in that direction, renaming classes and their memmbers to std-compatible names. QPartialOrdering cannot change, as it's pre-existing. So add a completely new type Qt::partial_ordering. Adding conversions from QPartialOrdering is left for a follow-up patch. As a drive-by, change `\c Less` to `\l Less` in the \class documentation blocks of the new classes. Amending c6fe64b17c87ec985f17389bf08eee46606862d4, which didn't have a ChangeLog: [ChangeLog][QtCore] Added Qt::{partial,weak,strong}_ordering as drop-in C++17 stand-ins for C++20's std::{partial,weak,strong}_ordering. Task-number: QTBUG-119108 Change-Id: Ib1296de6b708571a6abca8843ba36c114f6fd34f Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'src/testlib')
-rw-r--r--src/testlib/qcomparisontesthelper_p.h23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/testlib/qcomparisontesthelper_p.h b/src/testlib/qcomparisontesthelper_p.h
index 6948da9c80..432b6f5bd3 100644
--- a/src/testlib/qcomparisontesthelper_p.h
+++ b/src/testlib/qcomparisontesthelper_p.h
@@ -166,8 +166,8 @@ void testEqualityOperators(LeftType lhs, RightType rhs, bool expectedEqual)
(==, !=, <, >, <=, >=) for the \a lhs operand of type \c {LeftType} and
the \a rhs operand of type \c {RightType}.
- The \c OrderingType must be one of QPartialOrdering, QStrongOrdering, or
- QWeakOrdering.
+ The \c OrderingType must be one of Qt::partial_ordering,
+ Qt::weak_ordering, or Qt::strong_ordering.
The \a expectedOrdering parameter provides the expected
relation between \a lhs and \a rhs.
@@ -178,7 +178,7 @@ void testEqualityOperators(LeftType lhs, RightType rhs, bool expectedEqual)
\code
QDateTime now = QDateTime::currentDateTime();
QDateTime later = now.addMSec(1);
- QTestPrivate::testComparisonOperators(now, later, QWeakOrdering::Less);
+ QTestPrivate::testComparisonOperators(now, later, Qt::weak_ordering::less);
if (QTest:currentTestFailed())
return;
\endcode
@@ -186,19 +186,18 @@ void testEqualityOperators(LeftType lhs, RightType rhs, bool expectedEqual)
template <typename LeftType, typename RightType, typename OrderingType>
void testAllComparisonOperators(LeftType lhs, RightType rhs, OrderingType expectedOrdering)
{
- constexpr bool isQOrderingType = std::is_same_v<OrderingType, QPartialOrdering>
- || std::is_same_v<OrderingType, QWeakOrdering>
- || std::is_same_v<OrderingType, QStrongOrdering>;
-
+ constexpr bool isQOrderingType = std::is_same_v<OrderingType, Qt::partial_ordering>
+ || std::is_same_v<OrderingType, Qt::weak_ordering>
+ || std::is_same_v<OrderingType, Qt::strong_ordering>;
static_assert(isQOrderingType,
"Please provide, as the expectedOrdering parameter, a value "
- "of one of the Q{Partial,Weak,Strong}Ordering types.");
+ "of one of the Qt::{partial,weak,strong_ordering types.");
// We have all sorts of operator==() between Q*Ordering and std::*_ordering
- // types, so we can just compare to QPartialOrdering.
- const bool expectedEqual = expectedOrdering == QPartialOrdering::Equivalent;
- const bool expectedLess = expectedOrdering == QPartialOrdering::Less;
- const bool expectedUnordered = expectedOrdering == QPartialOrdering::Unordered;
+ // types, so we can just compare to Qt::partial_ordering.
+ const bool expectedEqual = expectedOrdering == Qt::partial_ordering::equivalent;
+ const bool expectedLess = expectedOrdering == Qt::partial_ordering::less;
+ const bool expectedUnordered = expectedOrdering == Qt::partial_ordering::unordered;
CHECK_RUNTIME_CREF(CHECK_RUNTIME_LR, lhs, rhs, ==,
!expectedUnordered && expectedEqual)