diff options
author | Marc Mutz <marc.mutz@qt.io> | 2023-11-29 19:34:32 +0100 |
---|---|---|
committer | Ivan Solovev <ivan.solovev@qt.io> | 2023-12-05 23:04:30 +0100 |
commit | 6e411012173217762e140f619b7d01e812ff8eaa (patch) | |
tree | fdbffb948f75999ba68659a57f706f787f8500f2 /tests/auto/corelib/global/qcompare | |
parent | ddb646d17b19b91e92116b817a30cba4a51efcd1 (diff) |
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 <ivan.solovev@qt.io>
Diffstat (limited to 'tests/auto/corelib/global/qcompare')
-rw-r--r-- | tests/auto/corelib/global/qcompare/tst_qcompare.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
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<Lhs, Rhs>) +#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 |