summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/text/qanystringview
Commit message (Collapse)AuthorAgeFilesLines
* QAnyStringView: fix char-ish ctors to not allocate memoryMarc Mutz2024-05-291-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extending the fromCharacter() tests to check for the construction to be noexcept and implicit turned up a few bugs: The constructor from char32_t was simply not marked as noexcept, even though all its operations were. So just mark it noexcept. The constructor from QChar, otoh, was never called, (certainly not for rvalues), because QString happens to be constructible from QChar (and QLatin1Char and QChar::SpecialCharactor), so due to perfect forwarding, the if_convertible_to<QString> ctor won, allocating a QString. This is a regression of Qt 6.5 compared to Qt 6.4. To fix this, exclude arguments that convert to QChar from matching the if_convertible_to<QString/QByteArray> ctors, taking care to not match those arguments that are already compatible_char<>s. This, in turn, creates a problem for implicit QASV construction from QLatin1Char and QChar::SpecialCharacter, because now that we've excluded them from the if_convertible_to<QString> ctor, calling the existing QChar or QString non-template constructors for these types would require two user-defined conversions (from said type to QChar/QString and from QChar/QString to QAnyStringView). That works for explicit construction, but we need implicit convertability. So bring out the big guns once more and add a perfectly-forwarding ctor for anything convertible to QChar. QChar itself is actually already handled by compatible_char<>, so the old QChar non-template ctor can go. The extra copy of the QChar argument will be optimized away by the compiler. [ChangeLog][QtCore][QAnyStringView] Fixed a regression where constructing a QAnyStringView from a char-like type (QChar, QLatin1Char, ...) would first construct a QString and only then convert that to QAnyStringView. Amends 812a0d3125cb89e340c59aa92cdc946862fb009d. This change is forward and backward BC and SC, but not behavior-compatible: certain operations detectably change noexcept'ness, and some arguments may now cause the resulting QAnyStringView to have a different encoding (though I really tried hard to avoid that). Since it's a regression, I proposed to pick this to the affected branches, 6.7 and 6.5 (6.6 is already closed at this point). Pick-to: 6.7 6.5 Fixes: QTBUG-125735 Change-Id: I86f37df5d80bee36db27e529c017cb73995a6831 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_QAnyStringView: add fromX for various char-like typesMarc Mutz2024-05-291-0/+59
| | | | | | | | | These were not covered by the existing tests. Pick-to: 6.7 6.5 6.2 Change-Id: I909ea3aa5b676904dc72ecf8ce32b73cca1b6af7 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QAnyStringView: use new comparison helper macrosIvan Solovev2024-03-022-37/+91
| | | | | | | | | | | Also extend unit-test to use new test helper functions. Remove the now-redundant test for three-way comparison, because it is covered by the test helper functions. Task-number: QTBUG-117661 Change-Id: I242b560c281245e04e34353c80000a20998fc677 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Bring back QASV::detects_US_ASCII_at_compile_timeIvan Solovev2024-03-011-5/+3
| | | | | | | | | | | | | | Even though undocumented, it's public API, doesn't hurt to carry along, and improves compiler coverage in the test, so let's not remove it. Found in 6.7 API review Amends 95e6fac0a5a1eee3aa23e4da0a93c6c25e32fb98. Pick-to: 6.7 Change-Id: Ia935036a69e0e678f22ac86b48a2c1c5e8c46733 Reviewed-by: Marc Mutz <marc.mutz@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>
* QAnyStringView: fix construction from QL1SV for bootstrapped buildsIvan Solovev2023-09-031-0/+28
| | | | | | | | | | | | | | | | | The SizeShift was not taken into account when constructing QASV from QL1SV. This is not an issue in normal Qt builds, because SizeShift == 0 there. But in bootstrapped case (and in future Qt 7) SizeShift changes to 2, and the bug becomes visible. The added test-cases do not really reveal the issue, because we do not run tests in bootstrapped builds, but at least they will help to prevent the issues in Qt 7. Pick-to: 6.6 6.5 6.2 Change-Id: I337b37b5230323a5357f48fd1c9bf799ca507d52 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QAnyStringView: add QDebug stream operatorMarc Mutz2023-07-061-0/+73
| | | | | | | | | | | | | | | | When QDebug::quoted(), indicates the encoding using the u/u8 prefixes or the _L1 suffix. This is information that might come in handy, and we plan to make it off-switchable (QTBUG-114936). The default should be true, though, for QAnyStringView, because we should confront users with this feature so they learn it exists. For concrete view types, changing the default behavior is probably not a good idea. [ChangeLog][QtCore][QAnyStringView/QDebug] Can now stream QAnyStringView into QDebug. Fixes: QTBUG-114935 Change-Id: Icd5bf700c8b7958e942468b54248487998f262d5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* CMake: Make corelib tests standalone projectsAlexandru Croitor2023-07-051-0/+6
| | | | | | | | | | | | | | | | | | Add the boilerplate standalone test prelude to each test, so that they can be opened with an IDE without the qt-cmake-standalone-test script, but directly with qt-cmake or cmake. Boilerplate was added using the following scripts: https://git.qt.io/alcroito/cmake_refactor Manual adjustments were made where the code was inserted in the wrong location. Task-number: QTBUG-93020 Change-Id: I28b6d3815c5f43d2c33ea65764f6f3f8f129eaf3 Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_QAnyStringView: test some longer strings and some containing nullsThiago Macieira2023-06-131-35/+102
| | | | | | | | Change-Id: Ieab617d69f3b4b54ab30fffd175c9cbb4f5d19b9 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com> Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* Short-live qIsConstantEvaluated()Thiago Macieira2023-06-111-1/+5
| | | | | | | | | | | | | | This is not q20::is_constant_evaluated() because it does not replace that for all compilers. Instead, it's our own version of it that may return false even in constant contexts. However, for the majority of our users, it will work even in C++17 mode. Updated QStringView and QAnyStringView to use it, which are the only two places in all of Qt that used std::is_constant_evaluated(). Change-Id: Ieab617d69f3b4b54ab30fffd175c50c517589226 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_QAnyStringView: fix warning of unused variable by using itThiago Macieira2023-05-121-1/+3
| | | | | | Pick-to: 6.5 6.2 Change-Id: Ieab617d69f3b4b54ab30fffd175c78ddb5fb919d Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* tst_Q(Any)StringView: check conversion from winrt::hstringMarc Mutz2023-03-311-0/+16
| | | | | | | | | | | | | | | | Instead of adding more QString::fromMyFavoriteStringImpl(), just check that QStringView{myFavoriteStringImpl}.toString() works. It does. Pick-to: 6.5 Task-number: QTBUG-111886 Change-Id: I337282611360b4a56a10c8acfd2d7d53ea196d5b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Make XmlStringRef convertible to QAnyStringView/QStringViewMarc Mutz2022-11-292-0/+5
| | | | | | | | | | | | | | | | | Both QStringView and QAnyStringView implicitly convert from any container with a fitting value_type, and working std::data, std::size, std::begin and std::end. Add these missing operations (and complementary ones) to XmlStringRef, so it implicitly converts to QStringView and QAnyStringView, too. Add a check to that effect and remove the now-superfluous operator QStringView(). Task-number: QTBUG-103302 Change-Id: I89d586cf64447a82022e06d546d7ee8339fc6dc7 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QAnyStringView: construct from any T implicitly convertible to ↵Marc Mutz2022-09-011-0/+10
| | | | | | | | | | | | | | | | | | | | | QString/QByteArray This includes QDBusReply, QProperty, and QStringBuilder expressions. The new constructor subsumes the QStringBuilder case without requiring jumping though hoops to delay the definition of the ctor the way we had to for the explicit QStringBuilder constructor, so remove the explicit QStringBuilder one again. [ChangeLog][QtCore][QAnyStringView] Can now be constructed from anything that implicitly converts to either QString or QByteArray. Fixes: QTBUG-105389 Change-Id: I0e584dd3e20d591381609a3329ef47cec7356ecc Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-08-231-1/+1
| | | | | | | Task-number: QTBUG-105718 Change-Id: I5d3ef70a31235868b9be6cb479b7621bf2a8ba39 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Add license headers to cmake filesLucie Gérard2022-08-031-0/+3
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: I3b98cdc55ead806ec81ce09af9271f9b95af97fa Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* tst_QAnyStringView: explicitly check the spaceship operatorMarc Mutz2022-06-141-0/+31
| | | | | | | | | | | | | | | We implicitly checked it, because, in C++20 builds, the non-equality relational operators are synthesized from it by the compiler, and we test those, but we didn't check that <=> returns strong_ordering. We now do. Pick-to: 6.4 6.3 6.2 Task-number: QTBUG-104108 Change-Id: Ieb19a2d4cb2d600d884f4e2e89e98c6187e23872 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* 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>
* Replace uses of _qs with _s in testsSona Kurazyan2022-04-071-1/+3
| | | | | | Task-number: QTBUG-101408 Change-Id: If092a68828a1e8056259cf90d035d9a87989244b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QAnyStringView: constexpr detect 8-bit ASCII as Latin 1Øystein Heskestad2022-03-211-0/+22
| | | | | | | | | | This has performance benefits when doing comparisons. The check is only performed at compile time. Task-number: QTBUG-101014 Change-Id: I55694b045fe5e75d9671d0a3a70c80d998cf98c8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Short live q20::ssize()!Marc Mutz2021-11-201-13/+1
| | | | | | | | | Extract the definition of q20::ssize() from tst_qanystringview.cpp, where it had to be placed for its backport to 6.2. Change-Id: I3f758c98a4b1efd453f4fc044b8d3f1a89de62d1 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QAnyStringView: fix broken implicit conversion from QStringBuilderMarc Mutz2021-11-191-0/+18
| | | | | | | | | | | | | | Need to use QConcatenable<>::ConvertTo for SFINAE, the forwarded type alias in QStringBuilder itself doesn't work. [ChangeLog][QtCore][QAnyStringView/QStringBuilder] Implicit conversion from QStringBuilder to QAnyStringView now works as advertised. Pick-to: 6.2 Fixes: QTBUG-98138 Change-Id: I1c300675cf43b13017bc56398ae5d8c1c51e64fe Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add an initial tst_QAnyStringViewMarc Mutz2021-11-183-0/+640
It's incomplet, but at least something. Task-number: QTBUG-98138 Pick-to: 6.2 Change-Id: I4630a44b62b190dee8a8cc07822dd6ec67dbdc84 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>