summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/global/qflags/tst_qflags.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* QTypeInfo: remove further usages of isPointer / isIntegralGiuseppe D'Angelo2022-12-301-2/+2
| | | | | | | In preparation to their deprecation / removal. Change-Id: Ia073a9f7caabbc06063a1e416b23cdb12788b283 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use SPDX license identifiersLucie Gérard2022-05-161-27/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Restore C++20-deprecated mixed-enum bitwise operatorsMarc Mutz2022-03-151-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | C++20 deprecated arithmetic on enum types. For enums used on QFlags<>, these operators have always been user-defined, but when the two enums are of different type, such as QFrame::Shape and QFrame::Shadow, the deprecation warning pops up. We have in the past fixed these in our headers by manual casts, but that doesn't help our users when our API requires them to OR together enums of different type. Until we can rework these APIs to use a variadic QFlags type, we need to fix it in an SC and BC way, which is what this patch sets out to do. The idea is simply to mark pairs of enums that are designed to be ORed together and replace the deprecated built-in bitwise operators with user-defined ones in C++20. To ensure SC and BC, we pass an explicit result type and use that to check, in C++17 builds, that it matches the decltype of the result of the built-in operator. This patch is the first in a series of similar patches. It introduces said markup macro and applies it to all enum pairs that create warnings on (my) Linux GCC 11.3 and Clang 10.0.0 builds. It is expected that more such markups are needed, for other modules, and for symmetry. Even with this patch, there is one mixed-enum warning left, in qxcbwindow.cpp. This appears to be a genuine bug (cf. QTBUG-101306), so this patch doesn't mark the enums involved in it as designed to be used together. This patch also unearthed that QT_TYPESAFE_FLAGS, possibly unsurprisingly so, breaks several mixed bitwise flags-enum operations (QTBUG-101344). Pick-to: 6.3 6.2 5.15 Task-number: QTBUG-99948 Change-Id: I86ec11c1e4d31dfa81e2c3aad031b2aa113503eb Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* tst_qflags: test w/and w/o QT_TYPESAFE_FLAGSMarc Mutz2022-03-081-10/+25
| | | | | | | | | | | | Also contains some fixes which fix the Windows build, amending e1b8257deeff67025d75b4b3c27b571b418eefee. Pick-to: 6.3 Fixes: QTBUG-101294 Fixes: QTBUG-101304 Change-Id: I779f50fc705ed32f0314daf28b39b477a7fe925d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* qtestmouse.h: compile with QT_TYPESAFE_FLAGSMarc Mutz2022-03-071-0/+44
| | | | | | | | | | | | Also include the comprehensive tests for bool cast compilation which I originally wrote to confirm that the QTEST_ASSERT() change should be™ correct. Pick-to: 6.3 Task-number: QTBUG-101406 Change-Id: I9a2871bfd4be9999b7a720bec775bba7aeffbe24 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* tst_qflags: don't suppress deprecation warningsMarc Mutz2022-03-031-1/+0
| | | | | | | | | | ... if there aren't any. Pick-to: 6.3 Change-Id: I8531e0c1c3ca41d1b1a9d55c9d11782bd63b6f76 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* tst_qflags: compile with QT_TYPESAFE_FLAGSMarc Mutz2022-02-281-3/+10
| | | | | | | | | | | | | In constExpr(), where code incorrectly assumed conversions to int or uint were implicit, make them explicit. In classEnum(), don't test bitwise operators between QFlags and int/uint when QT_TYPESAFE_FLAGS is in effect. Pick-to: 6.3 Fixes: QTBUG-101294 Change-Id: If119bf56dd12778f7231a9e76293c76e75354809 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QFlags: fix missing bitwise xor operators in QT_TYPESAFE_FLAGS buildsMarc Mutz2022-02-281-0/+23
| | | | | | | | | Add tests that cover them. Pick-to: 6.3 Fixes: QTBUG-101300 Change-Id: I5a8af4a91d796cc4d287b813bd5cc13da3d7e766 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Prefer QFAIL("Informative message") over QVERIFY(false)Edward Welbourne2021-06-141-5/+5
| | | | | Change-Id: I706b0aedfa870452331a8c2c488d55b279ee452a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QFlags: add test(Any)Flag(s)Giuseppe D'Angelo2021-05-151-0/+58
| | | | | | | | | | | | | | | QFlags was lacking a named function for testing whether a QFlags object contains _any_ of the bits set by a given enumerator/other QFlags. Drive-by, add testFlags taking a QFlags, not just an object of the enumeration; and simplify the implementation of testFlags to more closely follow what its documentation says it does. [ChangeLog][QtCore][QFlags] The testFlags, testAnyFlag and testAnyFlags functions have been added. Change-Id: Ie8688c8b0dd393d34d32bc7786cdcee3eba24d1c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace QtTest headers with QTestDavid Skoland2020-12-221-1/+1
| | | | | | | | | | | Complete search and replace of QtTest and QtTest/QtTest with QTest, as QtTest includes the whole module. Replace all such instances with correct header includes. See Jira task for more discussion. Fixes: QTBUG-88831 Change-Id: I981cfae18a1cabcabcabee376016b086d9d01f44 Pick-to: 6.0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Get rid of Q_COMPILER_CONSTEXPR checksAllan Sandfeld Jensen2020-11-171-4/+0
| | | | | | | Is required now. Change-Id: I62e95929d1649ea1390392230b619bd56d2a0349 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Cleanup QTypeInfoLars Knoll2020-08-261-2/+2
| | | | | | | | | | | | | | | Remove QTypeInfo::isStatic, as that's not used anymore in Qt 6. Also remove sizeOf, it's unused, and we have QMetaType for that if required. Remove all typeinfo declaractions for trivial types, as the default template covers them correctly nowadays. Finally set up a better default for isPointer, and do some smaller cleanups all over the place. Change-Id: I6758ed37dfc701feaaf0ff105cc95e32da9f9c33 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Properly deprecate Qt::MidButton in favor of Qt::MiddleButtonEdward Welbourne2020-08-221-3/+3
| | | | | | | | | | | | MidButton had its // ### Qt 5: remove me upgraded to Qt 6 at 5.0; but it dates back to 4.7.0 Replace the many remaining uses of MidButton with MiddleButton in the process. Pick-to: 5.15 Change-Id: Idc1b1b1816673dfdb344d703d101febc823a76ff Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Replace Qt CONSTEXPR defines with constexprAllan Sandfeld Jensen2020-08-141-1/+1
| | | | | | | | Both normal and relaxed constexpr are required by our new minimum of C++17. Change-Id: Ic028b88a2e7a6cb7d5925f3133b9d54859a81744 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Disable deprecation warnings in some testsTor Arne Vestbø2020-07-291-0/+2
| | | | | | | | The tests are testing deprecated functionality, which we still want to test. Change-Id: Iad6ed35800896170c17fe019c7a6ecda22398ac3 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Port Q_STATIC_ASSERT(_X) to static_assertGiuseppe D'Angelo2020-06-191-8/+8
| | | | | | | | | | | | | | | | | There is no reason for keep using our macro now that we have C++17. The macro itself is left in for the moment being, as well as its detection logic, because it's needed for C code (not everything supports C11 yet). A few more cleanups will arrive in the next few patches. Note that this is a mere search/replace; some places were using double braces to work around the presence of commas in a macro, no attempt has been done to fix those. tst_qglobal had just some minor changes to keep testing the macro. Change-Id: I1c1c397d9f3e63db3338842bf350c9069ea57639 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove unused functionality from QTypeInfoLars Knoll2020-06-181-2/+0
| | | | | Change-Id: I10fe4cde7a18047599e656cc3bb67b0dfe18a986 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Deprecate constructing QFlags from a pointerAllan Sandfeld Jensen2019-11-201-1/+1
| | | | | | | | | This was used to support QFlags f = 0 initialization, but with 0 used as a pointer literal now considered bad form, it had been changed many places to QFlags f = nullptr, which is meaningless and confusing. Change-Id: I4bc592151c255dc5cab1a232615caecc520f02e8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove handling of missing Q_COMPILER_INITIALIZER_LISTSAllan Sandfeld Jensen2019-05-021-5/+0
| | | | | | Change-Id: Id65b39c787235a051262544932e6717d076f1ea0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove handling of missing Q_COMPILER_CLASS_ENUMAllan Sandfeld Jensen2019-04-061-6/+0
| | | | | Change-Id: I1fd6d601e49e803b4c3308fb0ca41136c628afbc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix odd test in tst_qflagsAllan Sandfeld Jensen2018-10-171-1/+1
| | | | | | | | This test triggered a compiler warning for good reason, it made no sense, trying to change it to what it was probably meant to be. Change-Id: I01a848272b42dae2aaa58a4f5bed998644d864da Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Declare the operator| in the Qt namespace for QFlags in that namespacesOlivier Goffart2018-04-081-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a long overdue change so we don't break ADL of operator|. I think will not break source or binary compatibility. The problem is code like this: namespace Foo { struct MyStruct; MyStruct operator|(MyStruct, MyStruct); void someFunction() { fooLabel->setAlignement(Qt::AlignLeft | Qt::AlignTop) } } This would be an error before as ADL would find only the Foo::operator| and not the global one since the arguments are not in the global namespace. After this change, ADL works fine and this code compiles This bites people with misterious error, see questions on https://stackoverflow.com/questions/10755058/qflags-enum-type-conversion-fails-all-of-a-sudden https://stackoverflow.com/questions/39919142/broken-bitwise-or-operator-in-a-qt-project [ChangeLog][QtCore] QFlags's operator| for enum types in the Qt namespace are now declared in the Qt namespace itself. Change-Id: I021bce11ec1521b4d8795a2cf3084a0be1960804 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QFlags: support enum classes in setFlag()Giuseppe D'Angelo2017-11-241-0/+12
| | | | | | | Unary ~ is not defined for enum classes, so we need a cast. Change-Id: I79d495ebcc24ab960da8dae3be08eb307a9de448 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix test build with ICC: QFlags does not auto cast to uintThiago Macieira2017-04-281-9/+9
| | | | | | | | | | I don't know why. tst_qflags.cpp(114): error: no instance of function template "verifyConstExpr" matches the argument list argument types are: (Qt::MouseButton) tst_qflags.cpp(91): note: this candidate was rejected because there is a type mismatch after argument substitution Change-Id: I84e363d735b443cb9beefffd14b9581d77933cb8 Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
* Remove qtypetraits.h's contents altogetherGiuseppe D'Angelo2017-01-121-4/+4
| | | | | | | | | | | | | | | | | So that QFlags can use an (un)signed int matching the underlying type as identified by the compiler and not by us. Requires fixing a few warnings about sign conversion due to QFlags misusages in qtbase that were either plain wrong, or were relying on the enum being backed by an (un)signed int when it wasn't. Keep qtypetraits.h in the source tree in order to prevent source breaks if some downstream #includes it (note however that it did not contain any public API). Change-Id: Ib3a92b98db7031e793a088fb2a3b306eff4d7a3c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Rename QtPrivate::is_[un]signed to QtPrivate::Is[Un]signedEnumKai Koehne2016-11-091-4/+4
| | | | | | | | Any other use than for enums should use std::is_[un]signed. Make this explicit by renaming the type traits. Change-Id: I494158563c95c710e710d0d337f4e547006df171 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add setFlag method to QFlagsAndre Somers2016-02-081-0/+14
| | | | | | | | | | | | This makes implementing class methods that enable or disable a feature stored in a QFlags<> member easier. [ChangeLog][QtCore][QFlags] Added setFlag method to set or unset a flag Task-number: QTBUG-27100 Change-Id: Ic602abbbf3100df78f21b7918573744d1bbd18c1 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Updated license headersJani Heikkinen2016-01-211-17/+12
| | | | | | | | | | | | | From Qt 5.7 -> tools & applications are lisenced under GPL v3 with some exceptions, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new GPL-EXCEPT header instead of LGPL21 one (in those files which will be under GPL 3 with exceptions) Change-Id: I42a473ddc97101492a60b9287d90979d9eb35ae1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Use Q_DECL_RELAXED_CONSTEXPR in QFlagsOlivier Goffart2014-10-311-0/+14
| | | | | Change-Id: I91073f4bb71e554402fc13cbd0e9ba5b5b95bce0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Add support for initializer_list construction in QFlagsAdam Majer2014-07-021-0/+24
| | | | | | | | [ChangeLog][QtCore][QFlags] Added initializer_list constructor Task-number: QTBUG-39786 Change-Id: I36967c67b489c2a893fb031954f46f5243aba2c4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_QFlags: make constExpr() check compile on clang trunkMarc Mutz2013-11-071-1/+1
| | | | | | | | | | | | | | | | | The problem is the verifyConstExpr<>() line involving the ~ operator. The result as an integer is a value that can no longer be represented in an int. This is known at compile time and thus template deduction, which only has an int to match against, fails. To fix, use an unsigned int as the first template argument of verifyConstExpr<>(). Clang's error message for this is really sub-optimal, cf. http://llvm.org/bugs/show_bug.cgi?id=17834 Change-Id: I3a77dc54d2bee12b016d75724ac1bd7801f4cf2d Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Make QFlags enum flags (C++11 strict enums) friendlyAlbert Astals Cid2013-05-091-0/+116
| | | | | Change-Id: I9ccb3e4d281a545ca1845db4f6aa7ac6c04e8621 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* QFlags: use unsigned int when the enum's underlying is unsignedMarc Mutz2012-09-281-2/+16
| | | | | | | | | | | Replace storage and operator int() return types with unsigned int if the enum is unsigned. This fixes a number of exisiting warnings, in particular with Qt::MouseButton under GCC. Change-Id: Ia12d36212329aec3e9d62a5fbd38809a6c2b36d0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Work around what apparently is a GCC 4.6.0 bugThiago Macieira2012-03-251-1/+1
| | | | | | | | The QFlags::operator int() isn't being called, so GCC complains that this isn't an integer expression. Change-Id: I537d06fd4a52ecbcddf0ef67807b298c42d3e911 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* QFlags: mark as Q_PRIMITIVE_TYPEMarc Mutz2012-02-291-0/+9
| | | | | | | | | | | | | | | | | I originally tried to put Q_DECLARE_TYPEINFOs into Q_DECLARE_OPERATORS_FOR_FLAGS, to declare not only the flags type, but also the underlying enum as primitive, but too many users (arguably correctly) used Q_DECLARE_OPERATORS_FOR_FLAGS at (non-global) namespace scope where QTypeInfo would have been specialised in the wrong namespace. So specialise QTypeInfo for QFlags<T> only. Change-Id: I4af6e29aefbd9460a3d2bc6405f03cdf6b1096bc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-1/+1
| | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I311e001373776812699d6efc045b5f742890c689 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update contact information in license headers.Jason McDonald2012-01-231-1/+1
| | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I431bbbf76d7c27d8b502f87947675c116994c415 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Moving relevant tests to corelib/globalHolger Ihrig2011-08-301-0/+128
Task-number: QTBUG-21066 Change-Id: I011e601f599e11365c76598631a443b82ab9fb30 Reviewed-on: http://codereview.qt.nokia.com/3487 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@nokia.com> Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>