summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/text
Commit message (Collapse)AuthorAgeFilesLines
* Use SPDX license identifiersLucie Gérard2022-05-1633-898/+73
| | | | | | | | | | | | | 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>
* Remove remnants of the old Intel C++ compilerThiago Macieira2022-05-111-2/+2
| | | | | | | | | | | | | We don't support it any more. I don't think it has ever properly compiled Qt 6 (and it's no longer working for me against GCC 12's libstdc++ headers). If you report a bug against it, Intel support's first question is if you can try instead the new Clang/LLVM-based oneAPI C++ compiler. So we support only that one, which identifies itself as Q_CC_CLANG. Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16eb57a092c8439e Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Deprecate _qs and _qba literal operators in favor of _s and _baSona Kurazyan2022-05-022-2/+6
| | | | | | | | | | [ChangeLog][QtCore] Deprecated _qs and _qba literal operators for QString and QByteArray in favor of _s and _ba in the Qt::Literals::StringLiterals namespace. Task-number: QTBUG-101408 Change-Id: I26aee0055e3b4c1860de6eda8e0eb857c5b3e11a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace remaining uses of deprecated _qs with _sSona Kurazyan2022-05-021-3/+3
| | | | | | Task-number: QTBUG-101408 Change-Id: I1fda67c07e948af5017f0b99b67f8c20d7052033 Reviewed-by: Edward Welbourne <edward.welbourne@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>
* Fix qlocale_unix's handling of uiLanguages to take script into accountEdward Welbourne2022-04-271-0/+6
| | | | | | | | | | | | | | | Some languages have, in the same territory, locales for more than one script. In such cases, since we ignored the script, we got the one that is used by default, instead of the one actually asked for. Take the script into account. Added TODO comment in test listing the known examples of this; manually tested before and after the fix to verify the prior code was indeed getting it wrong and now does do it right. Change-Id: Iaf9201d6992bc39e6e9346ef8b7c69d418db7253 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Return more specific entries before less in QLocale::uiLanguages()Edward Welbourne2022-04-271-12/+12
| | | | | | | | | | | | | | | | | | The documentation overtly listed entries in this order but the code gave less specific entries before more specific (and the tests verified the same). This is now reversed. [ChangeLog][QtCore][QLocale] uiLanguages() now prefers more specific locale names over less specific ones, matching its own documentation, except where the system backend supplies them in some other order. This means a translation with the expected script and/or territory as well as language will be used in preference to a generic one for just the language, rather than only as a fall-back when the more generic one is missing. Fixes: QTBUG-102796 Change-Id: I3c7b3627afb51246df5a6ad0230e23b60af78071 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* 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>
* Fix assertion failure when parsing a doubly-invalid date-time textEdward Welbourne2022-04-071-1/+14
| | | | | | | | | | | | | | | | | | | | | | | When the date-time string falls in a spring-forward (so is invalid) and one of the fields of the parsed string doesn't match the format it's meant to (e.g. a single-digit seconds field when format ss was specified), a check that the current fall-back date-time is between the minimum and maximum for the parser object failed, triggering an assertion. In any case, an invalid default-value wasn't useful to the code that parsed a single section of the date-time string, so brute-force the current value to a valid date-time (when possible) using the usual round-trip via milliseconds since the epoch. Added the test-case which first revealed the problem, plus a couple more informed by it, to exercise the same code-paths with fewer things failing. Fixes: QTBUG-102199 Pick-to: 6.3 6.2 5.15 Change-Id: I658308614505ef25f4c97d0de6148acb54a65a0f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace uses of _qs with _s in testsSona Kurazyan2022-04-073-10/+16
| | | | | | Task-number: QTBUG-101408 Change-Id: If092a68828a1e8056259cf90d035d9a87989244b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Add literal operators for QString/QByteArray to StringLiterals namespaceSona Kurazyan2022-04-072-30/+80
| | | | | | | | | | | | [ChangeLog][QtCore] Added literal operators for _s and _ba for QString and QByteArray respectively in the Qt::Literals::StringLiterals namespace. Task-number: QTBUG-101408 Change-Id: I5cd4e7f36f614ea805cfecc27b91c5d981cd3794 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QByteArray/QVarLengthArray: add missing resize(n, v) overloadsMarc Mutz2022-04-061-0/+18
| | | | | | | | | | | | | | | | | | QList and QString had them, so add them to QByteArray and QVarLengthArray, too. In the QVLA case, we need to jump though a hoop or two to avoid having to duplicate all the reallocation logic. Nothing a few template tricks cannot solve. [ChangeLog][QtCore][QByteArray] Added resize(n, ch) overload. [ChangeLog][QtCore][QVarLengthArray] Added resize(n, v) overload. Fixes: QTBUG-102270 Change-Id: I0d281ae5b574f440f682e4a62427b434dcf5b687 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* We do in fact support 'F' format for floating-point valuesEdward Welbourne2022-04-012-1/+102
| | | | | | | | | | | | | | Update docs and add tests. [ChangeLog][QtCore] Documented existing support for 'F' format when converting floating-point numbers to strings in QLocale::toString(), hence equally for QString's floating-point formatting. Previously it was supported but the documentation neglected to mention it; it only differs from 'f' for infinities and NaN. Change-Id: Ic946c0f7b9e86fdf512daa3124bea57fc664b34b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Move some purely floating-point testing from tst_QLocale to tst_QNumericEdward Welbourne2022-04-011-24/+0
| | | | | | | | | The testing of infinity and NaN somewhat duplicated existing tests in tst_QNumeric and, in any case, belongs there. Change-Id: I6b5d1ff9767daf8e4bbe0025d3efab3d74ed35de Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Clean up and modernise tst_QLocale::fpExceptions()Edward Welbourne2022-04-011-15/+14
| | | | | | | | | | | Use the modern "portable" _clearfp() and _controlfp(), that work regardless of the hardware MS is running on, rather than the x86-specific _clear87() and _control87(); and move some defines into the #if-ery context in which they're used, rather than defining them regardless of whether they're used. Change-Id: I13abf2c85525b1182b99bc2c366aadd6b5fc656f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Allow brace initialization for some of QLatin1StringView constructorsSona Kurazyan2022-04-011-0/+5
| | | | | | | | | | | | | | | Removed "explicit" keyword from constructors taking (const char *, qsizetype) and (const char *, const char *). Switched to using brace initialization for creating QLatin1StringView in QtCore. [ChangeLog][QtCore][QLatin1StringView] The (const char *, qsizetype) and (const char *, const char *) constructors are no longer explicit. Change-Id: I4f6760692e4df60fe4231e86a25f6ea03cd1bf82 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* tst_QByteArrayView:: disable failing constexpr checks for GCCSona Kurazyan2022-04-011-0/+5
| | | | | | | | | | | | | | | When comiling with ubsan, GCC is being too restrictive and ignores that 'static constexpr char []' can never be nullptr. It tries to evaluate the comparison with nullptr, and fails with: error: ‘(((const char*)(& hello)) == 0)’ is not a constant Disable the checks when compiling with GCC. Fixes: QTBUG-101307 Pick-to: 6.3 6.2 Change-Id: I8322bb7cb326e06cd03b8b107c46a494c825087b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Android: enable tst_QLocaleIvan Solovev2022-03-291-9/+12
| | | | | | | | | | | | | | | | | | Do not try to properly specify a path to an external syslocale app, because the related test can't be executed on Android anyway. This fixes a failure in initTestCase() and allows to unblock other test-cases. Also skip systemLocale() test, because Android platform plugin already creates a custom QSystemLocale instance, so a hack with MySystemLocale does not work. As a drive-by: simplify the #ifery in initTestCase() and remove an unused second parameter of QSKIP() in emptyCtor_data(). Fixes: QTBUG-87414 Pick-to: 6.3 6.2 Change-Id: Iefc587062362469856fdca77f9ec9d96f5552e45 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: unblacklist tst_QStringConverter::convertUtf8()Ivan Solovev2022-03-281-3/+0
| | | | | | | | | | | The test was failing because test data was not provided correctly. That was fixed in 4aea86f5e8f4533a2a7ca9d7c21da8f81118c631 but the test was never unblacklisted. Fixes: QTBUG-87418 Pick-to: 6.3 6.2 Change-Id: Ibef7dcfaf59ef50f90d6538a562d03af17f065e0 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@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>
* Rename tst_qlatin1string and switch to using QLatin1StringViewSona Kurazyan2022-03-195-94/+93
| | | | | | Task-number: QTBUG-98434 Change-Id: Iec477835880263175edbc03f21b40f1ad67dbef0 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Add QByteArray::percentDecoded() as an instance methodEdward Welbourne2022-03-181-9/+9
| | | | | | | | | | | | | Percent-decoding was previously only present as a static method taking a QBA parameter; it might as well be an instance method of that parameter. Change most QBA tests to use it rather the static method. [ChangeLog][QtCore][QByteArray] percentDecoded() is now available as an instance method of the byte array to be decoded, equivalent to the static QByteArray::fromPercentEncoding(). Change-Id: I982101c44bdac5cc4041e85598d52ac101d38fa1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix a few more {QString, QByteArray}::count() deprecation warningsSona Kurazyan2022-03-171-4/+10
| | | | | Change-Id: I0be2d5e7a8f6af3bc1077ae6d1f20cc5da8f2266 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Tests: Do not depend on transitive includesFabian Kosmale2022-03-172-0/+2
| | | | | 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-173-311/+361
| | | | | | Pick-to: 6.3 6.2 Change-Id: I3c395d989e4659ebfa24b78f34b2a99769b734dc Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QStringTokenizer::toContainer(): allow more types of target containersMarc Mutz2022-03-151-0/+13
| | | | | | | | | | | | | | | | | | | The previous constraint called for the value_type of the container to exactly match the value_type of the tokenizer, which means toContainer() could only ever work on containers of views. But there is value in allowing QStringList, even though it works only on QL1S needles (QStringView -> QString isn't implicit). But users may have other types that for better or worse implicitly convert from views, so we shouldn't over-constrain the function. [ChangeLog][QtCore][QStringTokenizer] toContainer() now works on containers whose value_type can be constructed from the tokenizer's value_type. It no longer requires an exact match. Fixes: QTBUG-101702 Change-Id: Ie384cd1c4b51eaa57675f2a014141ceec8651c81 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QString::asprintf: check that passing field widths as arguments worksMarc Mutz2022-03-151-0/+6
| | | | | | | | Pick-to: 6.3 6.2 5.15 Change-Id: Ifb36179b9c26ce15378f10c2947c8cb1e38e10d4 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add some %-encoding round-trip tests that use % in the plain-textEdward Welbourne2022-03-141-1/+9
| | | | | | | | This was not previously tested. Change-Id: Icd287b519f6bc5d450f4490990ac78b0d06774f6 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Deprecate {QString, QByteArray}::count()Sona Kurazyan2022-03-121-0/+5
| | | | | | | | | | | | And remove their uses. [ChangeLog][QtCore][Deprecation Notice] Deprecated QString::count() and QByteArray::count() that take no parameters, to avoid confusion with the algorithm overloads of the same name. They can be replaced by size() or length() methods. Change-Id: I6541e3235ab58cf750d89568d66d3b1d9bbd4a04 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* 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-092-0/+44
| | | | | | | | [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>
* Add literal operators for QLatin1String and QLatin1CharSona Kurazyan2022-03-041-0/+45
| | | | | | | | | | | | The operators are declared in the Qt::Literals::StringLiterals namespace, to avoid collisions in the global namespace. [ChangeLog][QtCore][QLatin1String] Added literal operator""_L1 that converts string literals and chars to QLatin1String and QLatin1Char. Fixes: QTBUG-98434 Change-Id: Ia945a6acf4b8d4fbbb5f803264e4d79d7b17a8da Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Add compile-time checks for QLatin1StringSona Kurazyan2022-03-021-0/+60
| | | | | | | | Change-Id: If1b10a857275fb53c5d0b230bf6d11ce3e1ff2ca Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QLatin1String: add missing APIs for compatibility with Qt string viewsSona Kurazyan2022-03-021-23/+23
| | | | | | | | | | | | | | | As a drive-by, fixed misleading wording used in docs. [ChangeLog][QtCore][Potentially Source-Incompatible Changes][QLatin1String] Added QLatin1String(std::nullptr_t) constructor, which makes QLatin1String(0) call ambiguous. To fix the ambiguity, nullptr must be passed instead of 0. Task-number: QTBUG-98433 Change-Id: I2b888aa23469343d78aa640dc39a6028b77165dd Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QRegularExpression: print the pattern when warningGiuseppe D'Angelo2022-02-222-14/+43
| | | | | | | | | | Just as a minor debugging helper: when warning that an invalid regular expression object is being used to match, also print the used regular expression pattern. Change-Id: I0f99bcf4ca87ec67d04ed91d9dc315814f56d392 Fixes: QTBUG-76670 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Exclude denormal test cases if system doesn't support itTatiana Borisova2022-02-153-0/+25
| | | | | | | | | | | | - current INTEGRITY development pack don't support denormals for float and double. All values are rounded to 0. Task-number: QTBUG-99123 Pick-to: 6.2 6.3 Change-Id: Iaaacdc4210c7ac2ec3ec337c61164a1ade0efb01 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Cleanup tests that add test data to resources explicitlyAlexey Edelev2022-02-114-66/+4
| | | | | | | | | | | | Remove Integrity and Android specific code that explicitly adds test data to the resource files. qt_internal_add_test functions implicitly adds test data to resources for Android and Integrity platforms by default. Change-Id: Ia1d58755b47442e1953462e38606f70fec262368 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QByteArray: fix isUpper/isLowerGiuseppe D'Angelo2022-01-251-13/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 577d698b8e72bc0969ae7545a1a56d3a3d08bdda changed QString::isUpper / isLower behaviors to match Unicode semantics: a string is uppercase if it's identical to its own toLower/toUpper folding. These semantics come from Unicode so they're not up for debate. That commit however left QByteArray untouched. Generally speaking, we want to move away from QByteArray as "text storage" -- this has partially happened between Qt 5 and Qt 6, where QByteArray went from Latin-1 semantics to ASCII semantics. Still, QByteArray offers toUpper/toLower and isUpper/isLower and all this family of functions should be consistent in behavior. Apply the same fix that was applied to QString. [ChangeLog][Important Behavior Changes] The semantics of QByteArray::isLower() and QByteArray::isUpper() have been changed. Now lowercase (resp. uppercase) byte arrays are allowed to contain any character; a byte array is considered lowercase (resp. uppercase) if it's equal to its own toLower() (resp. toUpper()) folding. For instance, the "abc123" byte array is now considered to be lowercase. Previously, the isLower() (resp. isUpper()) functions checked whether the byte array only contained ASCII lowercase (resp. uppercase) characters, and was at least 1 character long. This had the side effect that byte array containing ASCII non-letters (e.g. numbers, symbols, etc.) were not lowercase nor uppercase. [ChangeLog][QtCore][QByteArray] QByteArray::isLower() and QByteArray::isUpper() now work correctly with empty byte arrays. The semantics of these functions have been changed. Pick-to: 6.3 6.2 Fixes: QTBUG-100107 Change-Id: Id56a42f01b2d1af5387bf0e6ccff0f824f757155 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Q(Static)ByteArrayMatcher: manage indexIn() overloadsMarc Mutz2022-01-231-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unlike QString and QStringView, QByteArrayView and QByteArray don't overload well. Solve the overload issue the usual way: by making the QByteArray one a Q_WEAK_OVERLOAD. This is trivial for QStaticByteArrayMatcher, which isn't exported, but require QT_REMOVED_SINCE magic for QByteArrayMatcher, which is. The additional const char* overload has shielded us from the worst fall-out so far, it seems, but it makes for a truly horrible overload set: matcher.indexIn(str, 3); Q: Is the 3 here the length of the haystack or the value of the from parameter? A: It depends on decltype(str)! If the (const char*, qsizetype, qsizetype=0) overload is the better match, then 3 limits the haystack's length. If, otoh, the (QByteArray(View), qsizetype) overload is the better match, then it's the value of the from parameter. As if this wasn't bad enough, QByteArray implcitly converts to const char* by default! A follow-up patch will therefore deprecate the (ptr, size) overloads, so we de-inline the QByteArrayView ones to avoid having to touch the implementation once more. Found during 6.3 API review. Pick-to: 6.3 Change-Id: I9640e0bdd298d651511adebcc85f314db9221d34 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QStaticByteArrayMatcher: fix searching in 2+GiB haystacksMarc Mutz2022-01-231-0/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a test (same techniques as for the 4+GiB check in tst_qcryptographichash). Takes ~1s to build the 4GiB test data here, and skips when RAM is too low: $ qtbase/tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher haystacksWithMoreThan4GiBWork [...] QDEBUG : tst_QByteArrayMatcher::haystacksWithMoreThan4GiBWork() created dataset in 891 ms [...] $ (ulimit -v 2000000; qtbase/tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher haystacksWithMoreThan4GiBWork) ********* Start testing of tst_QByteArrayMatcher ********* [...] SKIP : tst_QByteArrayMatcher::haystacksWithMoreThan4GiBWork() Could not allocate 4GiB plus a couple hundred bytes of RAM. Loc: [/home/marc/Qt/qt5/qtbase/tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher.cpp(242)] [...] Found during 6.3 API review. [ChangeLog][QtCore][QStaticByteArrayMatcher] Fixed searching in strings with size > 2GiB (on 64-bit platforms). Fixes: QTBUG-100118 Pick-to: 6.3 Change-Id: I1df420965673b5555fef2b75e785954cc50b654f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLatin1String: perform the comparison to another QL1S using memcmp()Thiago Macieira2022-01-171-12/+33
| | | | | | | | | | | | | | | | | | qstrncmp() would stop at the first null character, which isn't correct. The tests that had been disabled in tst_qstring.cpp (with an inaccurate comment) were actually passing. I've added one more to ensure that the terminating null is compared where needed. [ChangeLog][QtCore][QLatin1String and QUtf8StringView] Fixed a couple of bugs where two QLatin1Strings or two QUtf8StringViews would stop their comparisons at the first embedded null character, instead of comparing the full string. This issue affected both classes' relational operators (less than, greater than, etc.) and QUtf8StringView's operator== and operator!=. Pick-to: 5.15 6.2 6.3 Change-Id: I0e5f6bec596a4a78bd3bfffd16c90ecea71ea68e Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Remove unused .qrc filesJoerg Bornemann2022-01-174-23/+0
| | | | | | | | Task-number: QTBUG-94446 Change-Id: I136d8b4ab070a832866aa50b5701fc6bd863df8a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* tst_QString/tst_QByteArray: add checks for null-nessMarc Mutz2022-01-132-0/+79
| | | | | | | | | | We want to preserve nullness where possible. Test that various ctors do the right thing when presented with null input. Pick-to: 6.3 Change-Id: Ia1a1d4fb3c919b4fed2d9b87827815a1b5072c54 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix tst_qcollator run time issue on INTEGRITY deviceTatiana Borisova2022-01-121-5/+5
| | | | | | | | | | By GHS the only C locale is supported. Task-number: QTBUG-99123 Pick-to: 6.2 6.3 Change-Id: I3d89f1b2d9eb7f77b75e13a5ca65cebc24538890 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>