summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/global/qcomparehelpers
Commit message (Collapse)AuthorAgeFilesLines
* Fix moc include for tst_qcomparehelpersMårten Nordheim2024-05-131-1/+1
| | | | | | | The Q_OBJECT is in the header so it should use the moc_*.cpp form. Change-Id: I1aa91d9fd0013d7270d551326334ed4ee35f3c64 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* CMake: fix cross-compilation build: ${CMAKE_SYSTEM_PROCESSOR} is emptyThiago Macieira2024-04-241-1/+1
| | | | | | | | | | | | | | | | CMake Error at tests/auto/corelib/global/qcomparehelpers/CMakeLists.txt: 20 (if): if given arguments: "CMAKE_VERSION" "VERSION_GREATER_EQUAL" "3.20" "AND" "NOT" "MACOS" "AND" "NOT" "VXWORKS" "AND" "NOT" "(" "LINUX" "AND" "MATCHES" "aarch64" ")" Unknown arguments specified Pick-to: 6.7 Change-Id: I6979d02a7395405cbf23fffd17c900d8e25e4c0c Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Skip tst_qcomparehelpers_cpp23 on Linux armIvan Solovev2024-04-121-1/+1
| | | | | | | | | Because it causes issues in the CI Pick-to: 6.7 Change-Id: I8cd232abf1c4ee1d9417a8bff9aa3bcf5f893e8f Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* CMake: Make a few more auto tests standaloneAlexandru Croitor2024-03-141-0/+6
| | | | | | Pick-to: 6.7 Change-Id: I80988114bd906447a2ab712d5432a489e095a5c1 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Comparison helper macros: add an Attributes parameterIvan Solovev2024-02-203-4/+64
| | | | | | | | | | | | | Some of relational operators in Qt are marked with QT_ASCII_CAST_WARN (see e.g. String, QLatin1StringView). If we want to convert these operators to the new comparison helper macros, we need a way to preserve this attribute. My tests show that simply adding the attribute to the helper comparesEqual() and compareThreeWay() functions does not work, so we need to explicitly add it to each of the generated operators. Change-Id: I2940a70fe191326e8a2ebfb05b8da6e0f21a845c Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Refactor tst_qcomparehelpersIvan Solovev2024-02-164-188/+255
| | | | | | | | | | | | | | | | | Previously the test consisted of just one cpp file. An attempt to add more test cases to the file resulted in the minGW compiler complaining about a too large object file: Fatal error: tst_qcomparehelpers.cpp.obj: file too big This patch splits the implementation into a header and a cpp file. This itself does not fix the issues, but now we can add the new test cases in a separate cpp file. This patch also adds some comments that advocate doing so. Pick-to: 6.7 Change-Id: I451987370fa4e18b7ad81dfc064ea016f1d0da47 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Change license for tests filesLucie Gérard2024-02-041-1/+1
| | | | | | | | | | | | According to QUIP-18 [1], all tests file should be LicenseRef-Qt-Commercial OR GPL-3.0-only [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: I9657df5d660820e56c96d511ea49d321c54682e8 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* Exclude VxWorks from cxx 23 mode compilation of qcomparehelpersKrzysztof Sommerfeld2024-01-311-1/+1
| | | | | Change-Id: Ia217a76ad96851a3ad9dedae4ab3ff1c2b3b92c6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Introduce macros to simplify testing comparisonIvan Solovev2024-01-191-7/+2
| | | | | | | | | | | | | | | | | | | | | The problem with the QTestPrivate::testAllComparisonOperators() and QTestPrivate::testEqualityOperators() functions is that if they fail, they point into the helper function, but not into the actual test that called the helper function. This is specially annoying when some test calls the helper function multiple times. This patch introduces the helper macros QT_TEST_ALL_COMPARISON_OPS and QT_TEST_EQUALITY_OPS that wrap the respective function calls together with the QTest::currentTestFailed() check. If the test has failed, the macro generates a meaningful debug message with the original file name and line number. This patch also applies the new macros to qtbase. Task-number: QTBUG-119433 Pick-to: 6.7 Change-Id: Iad709de45e5bf53c82e7afa8e9f51e9275c1e619 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* tst_QCompareHelpers: fix narrowing warningMarc Mutz2024-01-121-8/+8
| | | | | | | | | | | | | | | | | | Warns MingW (or, in general, any GCC 13): warning: converting to 'QtPrivate::NativeFloat16Type' {aka '_Float16'} from 'double' with greater conversion rank See also a61d7529511c890aa595110b9320ea0bf53dd623. Fix by using ints instead. As a drive-by, make the variable constexpr. Amends 4b755bc11a8eadd156c65b7474c11e3ce822c6f1. Pick-to: 6.7 Change-Id: Ie3f3c51aa7e9323c7ba96c810d2e95247d222fd2 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* qcomparehelper.h: simplify compareThreeWay() SFINAE helpersMarc Mutz2023-12-071-3/+6
| | | | | | | | | | | | | There's no restriction on the number of enable_if's in a template-initializer, so simplify the compareThreeWay() constraints by having separate constraints each for LeftType and RightType. Fewer templates to instantiate = faster compile speed. As a drive-by, drop remove_reference_t. We control all users and all of them pass already-decayed types. Change-Id: I17c01c7aa1ac03bb6db4b0bef1371ebc0641641d Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Teach Qt::compareThreeWay() to support native float16 typesIvan Solovev2023-12-071-1/+19
| | | | | | | | | | Provide a custom variable template to detect float types and specialize it for QtPrivate::NativeFloat16Type. This will allow to enable three-way comparison for qfloat16. Task-number: QTBUG-104113 Change-Id: Id12c42c86f8dc9e233fe39776b0f0e28088de9e1 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* tst_QCompareHelpers: extract Qt/std-mapping into public headerMarc Mutz2023-12-051-12/+2
| | | | | | | We'll need this elsehere, too. Change-Id: I91a35a23dd201f7867898cee5b4d6743883f71fc Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Implement helper Qt::compareThreeWay() function for built-in typesIvan Solovev2023-11-282-27/+265
| | | | | | | | | | | | | | | | | | | | | | | | | The helper function RetType compareThreeWay(const T &left, const T &right) noexcept; is used for C++20-comparison macros. Normally it's the user's responsibility to provide this function as a hidden friend of the class which uses the comparison helper macros. For built-in types we provide the implementation inside the Qt namespace. We have to use custom IsIntegralType trait because libstdc++ only treats __{u}int128_t types as integral when compiling in -std=gnu++XX mode, and we compile Qt in -std=c++XX mode. This patch provides the implementations only for compareThreeWay() overloads, because there is no need to implement comparesEqual() for built-in types. It would just be equivalent to calling operator==(), so the user can do it directly. Task-number: QTBUG-104113 Change-Id: I7b3f395458e1ee4c64f442ad48bbf4fec4c19c52 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Implement compare helper macrosIvan Solovev2023-11-282-0/+500
These macros should unwrap into a proper set of equality and ordering operators, depending on the C++ standard being used. For C++17, all 6 operators (==, !=, <, >, <=, >=) are overloaded, while for C++20 only the overloads for opeartor==() and operator<=>() are provided. The macros are documented as internal for now. The macros rely on two helper functions: bool comparesEqual(LeftType lhs, RightType rhs); ReturnType compareThreeWay(LeftType lhs, RightType rhs); The comparesEqual() helper function is used to implement operator==() and operator!=(). The compareThreeWay() helper function is used to implement the four relational operators in C++17, or operator<=>() in C++20. ReturnType must be one of Qt::{partial,weak,strong}_ordering. When possible, the functions should also be declared constexpr and noexcept. It's the user's responsibility to provide the functions before using the macros. Implement a test case which applies the new macros to the dummy classes, and uses the new helper function to verify the comparison results. The MSVC compiler before version 19.36 has a bug, where it fails to correctly generate reverse opeerators in C++20 mode. Introduce a new Q_COMPILER_LACKS_THREE_WAY_COMPARE_SYMMETRY definition for such compiler versions, and use it to manually generate reversed operators when needed. Task-number: QTBUG-104113 Change-Id: Idc19d55df011fd616ff654f35a964e831b8ab93b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>