summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp
Commit message (Collapse)AuthorAgeFilesLines
* tst_QStringApiSymmetry: add overload check for (weak)QString/QBAVMarc Mutz2 days1-0/+13
| | | | | | | | Overload set to be used in QUuid soon. Pick-to: 6.7 6.5 Change-Id: I6f2c180bb7bb884d40f1691409e816405c3e5d47 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* tst_qstringapisymmetry: add qCompareThreeWay() checksIvan Solovev2024-03-181-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | Check that all string-like types implement compareThreeWay() as a (hidden) friend function. This test revealed some problems: because QByteArrayView is implicitly constructible from QLatin1StringView, the qCompareThreeWay() call sometimes picked the compareThreeWay() overloads with QByteArrayView instead of picking the "reversed" overloads that use QLatin1StringView. This was leading to wrong results, because QByteArrayView is interpreted as utf-8 data, not latin-1. Explicitly add the missing compareThreeWay() and comparesEqual() overloads. Note that relational operators were never affected by this problem, because in C++17 mode we explicitly generate the reversed versions, and in C++20 mode the compiler does that for us. Task-number: QTBUG-117661 Change-Id: Ia96af59c60ebf2fae6cf2a49231d6b6f401aceaa Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QByteArray: use comparison helper macrosIvan Solovev2024-03-021-24/+0
| | | | | | | | | | | | | | | | | | Replace the existing friend relational operators with the macros. Add the previously-missing relational opertors with QChar and char16_t. This allows to remove the last dummy relational operators and the macros to generate them in tst_qstringapisymmetry. Because of a bug in libstdc++[0], we have to explicitly keep the QBA vs QBA relational operators even in C++20 mode. This problem is specific to QByteArray, because it is convertible to const void *. [0]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114153 Task-number: QTBUG-117661 Change-Id: Iac7f81cd3274331b7c7695a51803321b511361c0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Q(Latin1)Char: use comparison helper macrosIvan Solovev2024-03-021-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Replace the existing friend relational operators with the macros. Add the previously-missing QChar vs `const char *` relational operators. These require out-of-line helper methods, because we need to interpret the `const char *` array as utf-8. The `const char *` relational operators cause ambiguities when comparing QChar with 0 (previously it was only handled by the nullptr_t overloads). As we have it in several places in our tests, I'd assume that the users can also do it. To resolve the ambiguities, mark the new relational operators as Q_WEAK_OVERLOADs. This allows to remove the dummy QChar vs `const char *` relational operators from tst_qstringapisymmetry, but at the same time requires that we introduce new dummy operators for QByteArray vs char16_t comparison. These will be fixed in a follow-up patch. For QLatin1Char - convert to uchar before doing the comparison, to match the behavior of QLatin1StringView and QChar. Extend QChar's unit tests. Task-number: QTBUG-117661 Change-Id: I9213fe05a5efdb96d48688f07bec9519f9887a77 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add QByteArrayView vs QChar and vs char16_t relational operatorsIvan Solovev2024-03-021-4/+0
| | | | | | | | | This allows to remove the dummy relational operators from tst_qstringapisymmetry. Task-number: QTBUG-108805 Change-Id: I7cb3154d6fcb571cafab6b318806f74bc8300448 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add missing QUtf8StringView relational operatorsIvan Solovev2024-03-021-6/+0
| | | | | | | | | | | | Add QU8SV vs QSV, QU8SV vs QChar, and QU8SV vs char16_t relational operators. This allows to get rid of the dummy relational operators in tst_qstringapisymmetry. Task-number: QTBUG-117661 Change-Id: If95d7418efd13c505ed0e3bef748b86ff55e623a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QString: use comparison helper macros - missing string views [3/3]Ivan Solovev2024-03-021-2/+0
| | | | | | | | | | | | | | | | | | | | | The comparison with QStringView works as is, there is no need to add explicit operators. Add the missing relational operators with QUtf8StringView. Once it is added, comparison of QString with u8"string literal" becomes ambiguous, so explicitly add operators for `const char8_t*` as well. This also makes the comparison with u8 string literals faster, because it now uses a view instead of constructing a QString. Adding QUtf8StringView overloads also makes comparison with `const char *` ambiguous if QT_RESTRICTED_CAST_FROM_ASCII is defined. To fix that, mark the overload as Q_WEAK_OVERLOAD. Luckily, we can just use the third Attributes parameter of the macro for that. Provide more unit-tests to cover the new relational operators. Task-number: QTBUG-117661 Change-Id: I60d1f4ad7ea607472deeb5c250e62f2bb7019268 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QString: use comparison helper macros - comparison with byte arrays [2/3]Ivan Solovev2024-03-021-1/+0
| | | | | | | | | | | | | | | | | | Use the comparison helper macros to replace the member relational operators for comparison with QByteArray and const char *. As QString and QByteArray are exported, we cannot simply remove the inline methods, so wrap them into QT_CORE_REMOVED_SINCE. Add relational operators with QByteArrayView. Provide more unit-tests for the comparison with the byte array types. This enables operator<=> for QString vs byte arrays in C++20 builds. Task-number: QTBUG-117661 Change-Id: I305343e1b6c5d78b10f2976573db4e904ba6b44b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QString/QByteArray: add slice() methodsAhmad Samir2024-02-291-0/+27
| | | | | | | | | [ChangeLog][QtCore][QString/QByteArray] Added slice() methods that work like sliced(), but modify the string/byte-array they are called on. Task-number: QTBUG-99218 Change-Id: I3075562983ef123d9aa022a2304c7e774cf2ea42 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Simplify QLatin1StringView vs byte array relational operatorsIvan Solovev2024-02-201-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | Now when QLatin1StringView implements relational operators with QByteArrayView in terms of new comparison helper macros and helper methods taking QByteArrayView, we can easily re-use these helper methods to provide comparison with QByteArray and const char *. QLatin1StringView already provided almost all of these operations, partly as hidden friend functions, partly as inline methods. Since the class is not exported, and the methods were inline, we can just remove all of them and replace them with the comparison helper macros. This should speed up the relational operators, because they do not construct string objects using QString::fromUtf8() anymore, but use QUtf8StringView instead. This also adds the previously missing QByteArray vs QLatin1StringView relational operators. Task-number: QTBUG-117661 Change-Id: I17a9185127ae130dab9409c6340a58f5d39f5a10 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add QStringView vs byte array relational operatorsIvan Solovev2024-02-201-6/+2
| | | | | | | | | | | | | | | | | | | | ... by using the new comparison helper macors. Note that by providing helper functions for QByteArrayView, we can support all three types: QByteArray, QByteArrayView, and const char *. Use the regular QT_NO_CAST_FROM_ASCII and QT_RESTRICTED_CAST_FROM_ASCII guards to disable the operators if the cast from ASCII is forbidden. Also use QT_ASCII_CAST_WARN on each operator. This allows to enable related tests in tst_qstringapisymmetry. Task-number: QTBUG-117661 Task-number: QTBUG-108805 Change-Id: I0d77c30245d8b5ac4b8cfd98d650c1885aca2005 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add QByteArrayView vs const char * relational operatorsIvan Solovev2024-02-201-4/+0
| | | | | | | | | | | | | | | | | | | | | | ... by using the new comparison helper macros. Also, convert the existing QByteArrayView relational operators to use these macros. An attempt to define the helper functions comparesEqual() and compareThreeWay() as hidden friends leads to compilation errors, because the QByteArrayView(QLatin1StringView) constructor gets somehow disabled. Apparently, it cannot satisfy the QtPrivate::IsContainerCompatibleWithQByteArrayView trait anymore. I could not find a reason for that, so I just defined the helper functions as static inline private members of QByteArrayView. This fixes the issue. This allows to enable related tests in tst_qstringapisymmetry. Task-number: QTBUG-108805 Change-Id: I35a69e99db8c61531ec726dab5b242b857f69e85 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add QByteArray vs QByteArrayView relational operatorsIvan Solovev2024-02-201-4/+0
| | | | | | | | | | ... by using the new comparison helper macors. This allows to enable related tests in tst_qstringapisymmetry. Task-number: QTBUG-108805 Change-Id: I2cef8f4a25889b74a921fea47995d59c3a49d368 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add QUtf8StringView vs byte array relational operatorsIvan Solovev2024-02-201-6/+0
| | | | | | | | | | | | | | | | | | | | | | | ... by using the new comparison helper macros. First the relational operators between QU8SV and QBAV where added, and this resulted in the ambiguities when comparing QU8SV vs QBA. So, the relational operators between QU8SV and QBA are also added in the same commit. This, in turn, resulted in ambiguities when comparing QU8SV and const char *, so add these relational operators as well. Use the regular QT_NO_CAST_FROM_ASCII and QT_RESTRICTED_CAST_FROM_ASCII guards to disable the operators if the cast from ASCII is forbidden. Also use QT_ASCII_CAST_WARN on each operator. This allows to enable related tests in tst_qstringapisymmetry. Task-number: QTBUG-117661 Task-number: QTBUG-108805 Change-Id: If7919496fdf4519fd2a9398397a39210aadba077 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add QLatin1StringView vs QByteArrayView relational operatorsIvan Solovev2024-02-201-2/+2
| | | | | | | | | | | | | | ... by using the new comparison helper macros. The operators are marked as QT_ASCII_CAST_WARN, like the pre-existing relational operators with QByteArray and const char *. This allows to enable related tests in tst_qstringapisymmetry. Task-number: QTBUG-117661 Task-number: QTBUG-108805 Change-Id: Ic9bcddffc25585edb7375c3e651d49d040a60454 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add QUtf8StringView vs QLatin1StringView relational operatorsIvan Solovev2024-02-161-1/+0
| | | | | | | | | | | | | | | ... by using the new comparison helper macros. This allows to remove dummy comparison operators from tst_qstringapisymmetry. This is also a pre-requisite for a follow-up commit that introduces relational operators between QLatin1StringView and QByteArrayView. Task-number: QTBUG-117661 Task-number: QTBUG-108805 Change-Id: I5837b457a777fddff1071bc252982e68d004fa94 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove extra semi-colonsTasuku Suzuki2024-02-061-1/+1
| | | | | Change-Id: I92fddb36cd136fd1bd627955f15d0559b9942d7e Reviewed-by: Allan Sandfeld Jensen <allan.jensen@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>
* tst_QStringApiSymmetry: add more invalid UTF-8 sequencesMarc Mutz2023-10-061-0/+2
| | | | | | | | | These represent US-ASCII characters incorrectly encoded as a two-octet UTF-8 sequence. Pick-to: 6.6 6.5 Change-Id: I5b1d58066d08cf61583dabcd71dd2f3ac7a3585a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* CI: Enable tests under corelib/text for Wasm platformPiotr Wierciński2023-07-101-0/+4
| | | | | | | | | | We are gradually enabling more tests for WebAssembly platform for better test coverage. Long linking time is no longer an issue due to test batching. Change-Id: I7ee9f877ecda726bc23d8dd2507c616bb381ebc1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* tst_qstringapisymmetry: silence a GCC warningAhmad Samir2023-04-081-0/+5
| | | | | | | | | | | | | | GCC complains: inlined from ‘constexpr QAnyStringView::QAnyStringView(const Container&) [with Container = QVarLengthArray<QChar, 1023>; typename std::enable_if<disjunction_v<QtPrivate::IsContainerCompatibleWithQStringView<T, void>, QtPrivate::IsContainerCompatibleWithQUtf8StringView<T, void> >, bool>::type <anonymous> = true]’ at src/corelib/text/qanystringview.h:215:64, inlined from ‘void tst_QStringApiSymmetry::overload() [with T = QVarLengthArray<QChar, 1023>]’ at /home/ahmad/devo/qt6-git/qtbase-qglobal/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp:1178:17: src/corelib/text/qanystringview.h:187:47: warning: ‘t’ may be used uninitialized [-Wmaybe-uninitialized] 187 | : m_data{str}, m_size{encodeType<Char>(str, len)} | ~~~~~~~~~~~~~~~~^~~~~~~~~~ Clang doesn't warn about this. Change-Id: I3476236630e886b087856acd22054bfb35deb451 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use consistent collation testability criteria in corelib/textMikolaj Boc2023-01-111-2/+3
| | | | | | | | | | | tst_qstringapisymmetry needs to use the same collation testability criteria as tst_qcollator, that is, the locales that may be tested without ICU and not on Mac nor Windows are only the system locale and C locale. Task-number: QTBUG-109954 Change-Id: I69f19ae28b3a16b3827c1eee62ae59fcfdf45209 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_QStringApiSymmetry: fix a typo and deal with the falloutMarc Mutz2022-12-291-1/+3
| | | | | | | | | | | | Turns out we don't support QStringView/QUtf8StringView comparison, and the only reason the corresponding test succeeded was because it contained a typo (QStringView instead of QUtf8StringView). Fix the typo and disable the now-failing test. Pick-to: 6.5 6.4 6.2 Change-Id: I2210a247aac66743851e53578172a563ee1e96f7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QAnyStringView: add substringing operationsMarc Mutz2022-12-081-2/+44
| | | | | | | | | | | | | | | | | | | | | | Add the full set of substringing operations: - mid/left/right (old-style) - sliced/first/last (new style) - chop/chopped/truncate The implementation is copied from QUtf8StringView, adjusted to use sliced() instead of the (ptr, n) ctor, so we need to deal with the tag twiddling only once, in sliced(). The documentation is also copied from QUtf8StringView. [ChangeLog][QtCore][QAnyStringView] Added substring functions sliced(), first(), last(), chop()/chopped(), truncate(). Change-Id: Ief454e9694519e97d9146fa84bc05dda1dded046 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Mate Barany <mate.barany@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QByteArrayView: Add mid/left/rightMårten Nordheim2022-12-021-0/+6
| | | | | | | Because they are too convenient to leave out. Change-Id: I844cfb794ce0f575c2c65075d9051b0b878a434f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add In-place utf-8 case-insensitive comparisonsØystein Heskestad2022-12-021-0/+17
| | | | | | | | | | | Also add optimizations for more string comparisons and add tests and benchmarks. [ChangeLog][QtCore][QString] Added utf-8 case-insensitive comparisons Fixes: QTBUG-100235 Change-Id: I7c0809c6d80c00e9a5d0e8ac3ebb045cf7004a30 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_QStringApiSymmetry: add checks for QByteArrayViewMarc Mutz2022-11-271-5/+100
| | | | | | | | | | | | | | | ... where checks for QByteArray existed before. The checks we can't add are - left/right/mid (legacy APIs not implemented in QBAV) - several relational operators, d/t ambiguities. Created QTBUG-108805 to track these. Task-number: QTBUG-108805 Pick-to: 6.4 6.2 Change-Id: I30cc9b29a228d69d32af51234f2c28221478a75c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* MSVC: Disable buggy conformance checkYuhang Zhao2022-10-181-1/+1
| | | | | | | | | | | | | | | /Zc:lambda seems buggy. Although in my experiments it works well for 99% Qt repos, it seems some tests will trigger the bug and it also blocks some new commits. So disable it for now, it's not stable enough. Now that this check is disabled, the workaround for tst_qstringapisymmetry is also not needed anymore, so remove the workaround as well. Partially reverts commit 8cb832090a8a0e7226904561f97c6de954d752ed Change-Id: Icf0ecbbaa6262522470e5f5dea05705985ab18f1 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* tst_QStringApiSymmetry: use startpos to deduplicate indexing data tagsEdward Welbourne2022-10-171-11/+15
| | | | | | | | | The tests for indexOf() and lastIndexOf() had duplicate data row tags, due to only using the needle and haystack, although some tests differed only in start position. Include start position where needed. Change-Id: I197d415265ab1a805f2d36fb88aec92ea8646f7a Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* tst_QStringApiSymmetry: avoid repetition in trimmed_data()Edward Welbourne2022-10-171-8/+10
| | | | | | | | | | Enclosing one string in each substring of another does not need to repeat the empty substring of the latter. Extracting the empty substring from different positions doesn't get different results. In the process, tidy up the code a bit. Change-Id: Ic66febbdadeaac0c466f4f1174d831a991d31e20 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* tst_QStringApiSymmetry: eliminate one duplicate of a mid_data() rowEdward Welbourne2022-10-171-1/+0
| | | | | | | | There were two copies of the same line in mid_data(), leading to duplicated data row tags. Change-Id: Ia21e855ff781b13fe18c932cff48cb0aabd12750 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* MSVC: Enable all possible conformance checksYuhang Zhao2022-10-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | For the full list, please refer to [1]. Needed to change the qstringapisymmetry unit test: In theory we don't need the array to be static and it did compile without any problems so far, indeed. However, with this patch applied, MSVC complains that the lambda function below can't access the array. I don't understand why, because we use [&] in the lambda and it should capture all the variables in theory, but in reality it failed to capture this variable in the end. And making the variable static solves this issue. Maybe it's a MSVC bug. Already tested locally. Most Qt repos build without any issues, only very few repos are not tested, as my local environment can't build them. [1] https://docs.microsoft.com/en-us/cpp/build/reference/zc-conformance?view=msvc-170 Change-Id: I658427aa171ee1ae26610d0c68640b2f50789f15 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* tst_QStringApiSymmetry: use QCOMPARE_EQ instead of QCOMPAREIvan Solovev2022-06-031-168/+168
| | | | | | | | | | | | | | | | | | | | This allows to defer the toString() invocation until it is really needed, and so allows to speed-up the test execution. I was testing a release shared developer build, running tst_QStringApiSymmetry 10 times before the change, and 10 times after the change, and then taking the average execution duration, as reported in the log. Before the change (using QCOMPARE): 51ms After the change (using QCOMPARE_EQ): 45ms As we see from the results, the benefit is around 10%. Task-number: QTBUG-98873 Task-number: QTBUG-98874 Change-Id: Ifcfbcca1f2c1eaf82c7f1a9098fa1512a269cbf8 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-28/+3
| | | | | | | | | | | | | 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>
* Implement support for '0b' prefix in toInt() etcMarc Mutz2022-04-281-4/+1
| | | | | | | | | | | | | | | | | | | | [ChangeLog][QtCore][QByteArray/QByteArrayView/QLatin1String/QString/QStringView] The string-to-integer conversion functions (toInt() etc) now support the 0b prefix for binary literals. That means that base = 0 will recognize 0b to mean base = 2 and an explicit base = 2 argument will make toInt() (etc) skip an optional 0b. [ChangeLog][QtCore][Important Behavior Changes] Due to the newly-introduced support for 0b (binary) prefixes in integer parsing, some strings that were previously rejected as invalid now parse as valid. E.g., Qt 6.3 with autodetected bases would have tried to parse "0b1" as an octal value and fail, whereas 6.4 will parse it as the binary literal and return 1. Fixes: QTBUG-85002 Change-Id: Id4eff72d63619080e5afece4d059b6ffd52f28c8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* tst_qstringapisymmetry: check toInt() etc also with base != 0Marc Mutz2022-04-171-0/+119
| | | | | | | | | | | This shows we're lacking support for the 0b prefix, and, as it turns out, there's a request for it. Task-number: QTBUG-85002 Pick-to: 6.3 Change-Id: Ie201c84bf906a7e482b929301699ceb429b53c14 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Tests: Do not depend on transitive includesFabian Kosmale2022-03-171-0/+1
| | | | | Change-Id: Ibc6a948480a904913a5427e6408d4d296784fb4f Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Add QStringView::localeAwareCompare()Sona Kurazyan2022-03-171-0/+4
| | | | | | | | | | | | | | QString already has a localeAwareCompare(QStringView, QStringView) static method. Use it in QStringView::localeAwareCompare(QStringView). [ChangeLog][QtCore][QStringView] Added QStringView::localeAwareCompare(). Task-number: QTBUG-98431 Change-Id: Iec3865a5439d9fb653cc1150da21042186bdee98 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Move localeAwareCompare tests from tst_qstring to tst_qstringapisymmetrySona Kurazyan2022-03-171-4/+354
| | | | | | Pick-to: 6.3 6.2 Change-Id: I3c395d989e4659ebfa24b78f34b2a99769b734dc Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Add an overload of QStringView::count() for QLatin1StringSona Kurazyan2022-03-091-3/+2
| | | | | | | | | | | | Required for the API symmetry between QStringView and QLatin1String. [ChangeLog][QtCore][QStringView] Added an overload of QStringView::count() for QLatin1String. Change-Id: Ic49a4b31e8f6f0969eff0f792654d23a60e06c49 Task-numer: QTBUG-98431 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Add QLatin1String::count(needle)Sona Kurazyan2022-03-091-0/+13
| | | | | | | | [ChangeLog][QtCore][QLatin1String] Added QLatin1String::count(needle). Task-number: QTBUG-98433 Change-Id: I31c9fdf14fd81500722ff9f5998eadf0e6cedc5c Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* tst_qstringapisymmetry: check expected overloads are selectedMarc Mutz2022-03-081-12/+59
| | | | | | | | | | | Check that the expected overloads are selected in QString/QAnyStringView overload sets. Pick-to: 6.3 Change-Id: I38148c20a72eb60cf86844a39fe0ed419d2fa562 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Add numeric conversion methods to QLatin1StringSona Kurazyan2022-03-051-0/+2
| | | | | | | | | | | [ChangeLog][QtCore][QLatin1String] Added numeric conversion methods. Task-number: QTBUG-98433 Change-Id: I414577ae715debe3d5ba9c6a160859aca790e017 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* tst_qstringapisymmetry: check QString/QAnyStringView overloads ↵Marc Mutz2022-03-041-0/+22
| | | | | | | | | | | | | | | | | | | | w/Q_WEAK_OVERLOAD flipped This overload set may come in handy to cushion some of the concerns regarding replacing QString functions with QAnyStringView ones. Overloading with a Q_WEAK_OVERLOAD QAnyStringView function requires users to jump through hoops in order to avoid the QString overload, but with the Q_WEAK_OVERLOAD roles reversed, the QAnyStringView overload becomes the preferred version, relegating the QString overload to a fall-back to facilitate sharing where it makes sense (e.g. for QObject::setObjectName()). Pick-to: 6.3 Change-Id: Ic65ead505beee627976a306e2d430e800540a600 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Fix tst_qstringapisymmetry::count* to test all argument combinationsSona Kurazyan2022-03-041-12/+27
| | | | | | | | | | | | | | Use two template parameters for the haystack and needle types, to test all possible combinations of all argument types. Note that the tests for QByteArray::count() are removed: it doesn't make sense to have them in tst_qstringapisymmetry, and we already have the symmetry tests for QByteArray in tst_qbytearrayapisymmetry. Change-Id: I33901fd135eb7433f0d45300a7248aef4d40324a Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix an error in tst_QStringApiSymmetry::count_impl()Sona Kurazyan2022-03-041-1/+1
| | | | | | | | | | | | Don't use the haystack as needle when testing count() for QLatin1String. This wasn't caught earlier, since QLatin1String has no count() yet, and the codepath was never tested. Pick-to: 6.3 6.2 Change-Id: I2764070894ddce047eceaea52456e5a521252dab Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QString et al: fix lastIndexOf() API asymmetryMarc Mutz2021-12-021-0/+16
| | | | | | | | | | | | | | | | | Commit 6cee204d56205e250b0675c9c6d4dd8a2367f3c4 introduced overloads of lastIndexOf() which drop the 'from' argument, inadvertently fixing QTBUG-80694, but failed to provide the new overloads for all existing lastIndexOf() overloads, making the fix for QTBUG-80694 incomplete. This patch completes the fix, by adding the missing overloads (for char-likes) and also adds the missing (non-regex) tests to tst_qstringapisymmetry. Also amends 1c164ec7f21a78025475c561a70b94d1e3dd6bb6. Fixes: QTBUG-80694 Change-Id: Ib4b3d597d658ce2edf01a2bce0d711ecea593d6e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix overflow issue on parsing min-qint64 with its minus sign repeatedEdward Welbourne2021-10-261-0/+1
| | | | | | | | | | | The call to std::from_chars() accepts a sign, but we've already dealt with a sign, so that would be a second sign. Check the first character after any prefix is in fact a digit (for the base in use). This is a follow-up to commit 5644af6f8a800a1516360a42ba4c1a8dc61fc516. Fixes: QTBUG-97521 Change-Id: I65fb144bf6a8430da90ec5f65088ca20e79bf02f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove checks for features available in C++17Ievgenii Meshcheriakov2021-10-021-2/+0
| | | | | | | | | | This patch removes most of the checks that are made using C++20 __cpp_* macros for features available in C++17 and earlier. Library feature check macros (__cpp_lib_*) are unaffected. Change-Id: I557b2bd0d4ff09b13837555e9880eb28e0355f64 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add isValidUtf8() methods to QUtf8StringView and QByteArray{,View}Ievgenii Meshcheriakov2021-09-221-0/+83
| | | | | | | | | | | | | | | The new methods return true if the string contains valid UTF-8 encoded data, or false otherwise. [ChangeLog][QtCore][QByteArray] Added isValidUtf8() method. [ChangeLog][QtCore][QByteArrayView] Added isValidUtf8() method. [ChangeLog][QtCore][QUtf8StringView] Added isValidUtf8() method. Task-number: QTBUG-92021 Change-Id: I5d0cb613265d98b1f189c5f5cc09c1f7db302272 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>