From 6e411012173217762e140f619b7d01e812ff8eaa Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 29 Nov 2023 19:34:32 +0100 Subject: [PATCH] tst_QCompare: restore some test coverage to QPartialOrdering When I split Qt::partial_ordering off of QPartialOrdering, O duplicated the partialOrdering() test, but lost the conversion() part of the tests. This patch brings them back. Because we maintained the test coverage for Qt::partial_ordering, it suffices to check that QPartialOrdering::X correctly maps to std::partial_ordering::x. The rest follows from transtivity of equality. We're still lacking conversions of QPartialOrdering to Qt::_ordering types. That will be the subject of a follow-up patch. Amends 4b6f757020382ed157bf6beb572549f05e881359. Change-Id: I1938d09f696ed8d58143dbacccb72cfd54ca12dd Reviewed-by: Ivan Solovev --- .../corelib/global/qcompare/tst_qcompare.cpp | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/auto/corelib/global/qcompare/tst_qcompare.cpp b/tests/auto/corelib/global/qcompare/tst_qcompare.cpp index 7561fbdc38..ba382d57fb 100644 --- a/tests/auto/corelib/global/qcompare/tst_qcompare.cpp +++ b/tests/auto/corelib/global/qcompare/tst_qcompare.cpp @@ -13,6 +13,7 @@ class tst_QCompare: public QObject Q_OBJECT private slots: void legacyPartialOrdering(); + void legacyConversions(); void stdQtBinaryCompatibility(); void partialOrdering(); void weakOrdering(); @@ -131,6 +132,27 @@ void tst_QCompare::legacyPartialOrdering() static_assert(!(0 >= QPartialOrdering::Greater)); } +void tst_QCompare::legacyConversions() +{ +#define CHECK_CONVERTS(Lhs, Rhs) static_assert(std::is_convertible_v) +#define CHECK_ALL(NS) do { \ + CHECK_CONVERTS(QPartialOrdering, NS ::partial_ordering); \ + static_assert(QPartialOrdering::Less == NS ::partial_ordering::less); \ + static_assert(QPartialOrdering::Greater == NS ::partial_ordering::greater); \ + static_assert(QPartialOrdering::Equivalent == NS ::partial_ordering::equivalent); \ + static_assert(QPartialOrdering::Unordered == NS ::partial_ordering::unordered); \ + \ + CHECK_CONVERTS(NS ::partial_ordering, QPartialOrdering); \ + } while (false) + +#ifdef __cpp_lib_three_way_comparison + CHECK_ALL(std); +#endif // __cpp_lib_three_way_comparison + +#undef CHECK_ALL +#undef CHECK_CONVERTS +} + void tst_QCompare::stdQtBinaryCompatibility() { #ifndef __cpp_lib_three_way_comparison