summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/text
Commit message (Collapse)AuthorAgeFilesLines
* Android: tst_QByteArray::base64_2GiB() times out or gets terminatedAssam Boudjelthia2022-08-181-0/+3
| | | | | | | | | | Android kills this test case which tries to use too much memory, or it times out. Pick-to: 6.4 6.3 6.2 Task-number: QTQAINFRA-4748 Change-Id: Ifce92533d50f4c463ee10fe80e7654ad16172a35 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* tst_qbytearray: remove qCompress_data for QT_NO_COMPRESSMarc Mutz2022-08-151-2/+2
| | | | | | | | | The _data function is useless without its test function (and it's not used in other _data functions). Pick-to: 6.4 6.3 6.2 5.15 Change-Id: I7aa6006ed1a9d89008577b750af4ea717dae237f Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Add Latin 1 case-insensitive Boyer-Moore searcherØystein Heskestad2022-08-041-0/+104
| | | | | | | | | | The std::boyer_moore_searcher is buggy for older verions of Microsoft's STL, and missing in AppleClang's libc++ with an inefficient fall back. Fixes: QTBUG-100236 Change-Id: Ic3cc916946546d2ef78456cd15e1425d957b989d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Make 'zz' format an alias for 'z' in time format stringsEdward Welbourne2022-08-031-1/+1
| | | | | | | | | | | | | | Also document the (seldom helpful) handling of over-long repeats of a format. Add test to QDateTime and amend QLocale test. [ChangeLog][QtCore][QDateTime] Doubling the 'z' format in a date-time or time format string now produces the same output as a single 'z'. Previously, this would have produced two copies of the milliseconds field (eliding any trailing zeros in each). Contrast with 'zzz', which produces the full milliseconds field, including any trailing zeros. Change-Id: I4c60462b062fee4079370096d745c191c1939506 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add license headers to cmake filesLucie Gérard2022-08-0331-0/+93
| | | | | | | | | | | | 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>
* QRegularExpression: introduce (global)matchViewGiuseppe D'Angelo2022-07-291-16/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QRegularExpression::match (and globalMatch) is currently overloaded for QString and QStringView. This creates a subtle API asymmetry: QRegularExpression re; auto m1 = re.match(getQString()); // OK auto m2 = re.match(getStdU16String()); // Dangling This goes against our decision that every time that there's a possible lifetime issue at play, it should be "evident". Solving the lifetime issue here is possible, but tricky -- since QRegularExpression is out-of-line, one needs a type-erased container for the input string (basically, std::any) to keep it alive and so on. Instead I went for the simpler solution: deprecate match(QStringView) and introduce matchView(QStringView) (same for globalMatch). This makes it clear that the call is matching over a view and therefore users are supposed to keep the source object alive. Drive-by, remove the documentation that says that the QString overloads might not keep the string alive: they do and forever will. [ChangeLog][QtCore][QRegularExpression] Added the matchView() and globalMatchView() functions that operate on string views. The match(QStringView) and globalMatch(QStringView) overloads have been deprecated. Change-Id: I054b8605c2fdea59b556dcfea8920ef4eee78ee9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* CMake: Don't use PUBLIC_LIBRARIES for tests and test helpersAlexandru Croitor2022-07-2810-13/+13
| | | | | Change-Id: I9b7404e1d3a78fe0726ec0f5ce1461f6c209e90d Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* QByteArray: fix base64 round-trip w/more than 2GiB dataMarc Mutz2022-07-261-0/+40
| | | | | | | | | | | | | | | | | There was an explicit int cast in fromBase64Encoding() which was never ported to qsizetype and therefore truncated the result. Fix by removing the int cast. Add a test, optimize it for as low memory usage as possible, given we need to work in input and output data each in excess of 2GiB. Fixes: QTBUG-104985 Pick-to: 6.4 6.3 6.2 Change-Id: I9c0924957e62e5cb3003132cd811b8b0315d8ac1 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* tst_QByteArray: fix custom QCOMPARE for QBAs > 2GiBMarc Mutz2022-07-201-1/+1
| | | | | | | | | | | | | | | The tst_QByteArray test redefines the QCOMPARE macro to check the LHS to be NUL-terminated. Because the code was never ported from int to qsizetype, it fails for QByteArrays of size > 2GiB. Fix by porting to qsizetype. Pick-to: 6.4 6.3 6.2 Task-number: QTBUG-104985 Change-Id: Ib3951b0efed5f734ae1324ea2d455bb7762fb9c4 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add wasm exception for tst_qcharDavid Skoland2022-07-111-0/+5
| | | | | | | | | Since wasm doesn't like filesystems that well, we omit this test in tst_qchar for wasm, this allows us to still run the test without the case where it needs to read the normalization file. Change-Id: I37e54d97e119f94e1a9ca53917d0b93183321899 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* QString: fix lifetime issues with QRegularExpression APIsGiuseppe D'Angelo2022-07-101-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QString has several functions taking a QRegularExpression: indexOf(), contains(), and so on. Some of those have an out-argument of type QRegularExpressionMatch, to report the details of the match (if any). For instance: QRegularExpression re(...); QRegularExpressionMatch match; if (string.contains(re, &match)) use(match); The code used to route the implementation of these functions through QStringView (which has the very same functions). This however opens up a lifetime problem with temporary strings: if (getString().contains(re, &match)) use(match); // match is dangling Here `match` is dangling because it is referencing data into the destroyed temporary -- nothing is keeping the string alive. This is against the rules we've decided for Qt, and it's also asymmetric with the corresponding code that uses QRegularExpression directly instead: match = re.match(getString()); if (match.hasMatch()) use(match); // not dangling ... although we've documented not to do this. (In light of the decision we've made w.r.t. temporaries, the documentation is wrong anyways.) Here QRE takes a copy of the string and stores it in the match object, thus keeping it alive. Hence, extend the implementation of the QString functions to keep a (shallow) copy of the string. To keep the code shared as much as possible with QStringView, in theory one could have a function taking a std::variant<QString, QStringView> and that uses the currently active member. However I've found that std::variant here creates some abysmal codegen, so instead I went for a simpler approach -- pass a QStringView and an optional pointer to a QString. Use the latter if it's loaded. QStringView has some inline code that calls into exported functions, so I can't change the signature of them without breaking BC; I'm instead adding new unexported functions and a Qt 7 note to unify them. Change-Id: I7c65885a84069d0fbb902dcc96ddff543ca84562 Fixes: QTBUG-103940 Pick-to: 6.2 6.3 6.4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add QStringDecoder::decoderForHtml()Lars Knoll2022-06-211-20/+64
| | | | | | | | | | | | | | Now that QStringConverter can handle non UTF encodings through ICU, add a way to get a decoder for arbitrary HTML code. Opposed to QStringConverter::encodingForHtml(), this method will try to create a valid string decoder also for non unicode codecs. Pick-to: 6.4 Change-Id: I343584da1b114396c744f482d9b433c9cedcc511 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Long live the ICU-based QStringConverter interface!Fabian Kosmale2022-06-193-2/+280
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds support for additional codecs to QStringConverter when ICU is available. We store the converter in the state (d[0]), and its canonical name in d[1]. We need the name there, as in the clear function we close the UConverter, and set the pointer to null. Consequently, the actual conversion functions might need to re-open the converter again. The advantage of this approach is that clear is used in the destructor of State, and with this approach we properly clean up the state. There is however a disadvantage: The clear function was so far also used for resetting the state when QStringConverter::resetState . Discarding the whole Uconverter for that is however rather costly. For that reason we modify resetState to call a new function, State::reset. For existing converters, it behaves the same as clear; for the ICU based converter, we call the more efficient ucnv_reset. Code compiled against Qt 6.4 can benefit from this more efficient version; code compiled against older Qt versions will continue to work, as the conversion functions can just recretate the converter from the name. We can distinguish between ICU and non-ICU converters by checking if the UsesIcu flag is set. QStringConverter::name is changed to return the name stored in d[1]. The interface of the ICU converter has a dummy name, so code using the old name function from QT < 6.4 still returns something, namely a message asking the user to recompile. The function is moved out of line, as we need to check for the private ICU feature, and want to avoid having that check in the public header. As the QStringConverter ctor taking a name now can allocate memory, it can no longer be noexcept. Removing the noexceptness is safe, as it was only added after Qt 6.3. Note that we cannot extend the API consuming or returning Encoding, as we use Encoding values to index into an array of converter interfaces in inline API. Further API to support getting an ICU converter for HTML will be added in a future commit. Currently, the code depending on ICU is enabled at compile time if ICU is found. However, in the future it could be moved into a plugin to avoid a hard dependency on ICU in Core. [ChangeLog][Corelib][Text] QStringConverter and API using it now supports more text codecs if Qt is compiled with ICU support. Fixes: QTBUG-103375 Change-Id: I7afb92fc68ef994179ebc7a3aa73beebb1386204 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QStringConverter: fix use-after-free in the stack in the testThiago Macieira2022-06-151-7/+11
| | | | | | | | | Detected by ASan. Introduced by aef27c5aa2f43e8e34970168dfc517062cc87db8 Pick-to: 6.3 6.4 Fixes: QTBUG-104261 Change-Id: Id0fb9ab0089845ee8843fffd16f88bdeb4f42c7c Reviewed-by: Lars Knoll <lars.knoll@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>
* 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>
* QStringConverter: Do not crash if invalidFabian Kosmale2022-05-251-0/+56
| | | | | | | | | | | Attempting to use an invalid QStringConverter would so far have resulted in a crash, as we would dereference the null iface pointer. Fix this by inserting adequate checks, and ensure that hasError returns true if we attempt to en/decode with an invalid converter. Pick-to: 6.2 6.3 Change-Id: Icf74bb88cd8c95685481cc0bd512da99b62f33e6 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* tst_qtextboundaryfinder: Remove full copies of data filesIevgenii Meshcheriakov2022-05-243-9541/+0
| | | | | | | | | | There are no commented out test cases remaining, so the normal test vectors are identical to full test vectors. Fixes: QTBUG-97537 Pick-to: 6.3 Change-Id: I987f178f192e1c8e2d998d36499fdce84f237e77 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QUnicodeTools: Fix line breaking before open parenthesesIevgenii Meshcheriakov2022-05-241-24/+24
| | | | | | | | | | | | | | UAX #14, revision 45 (Unicode 13) has changed rule LB30 to only trigger if the open parentheses is non-wide: (AL | HL | NU) × [OP-[\p{ea=F}\p{ea=W}\p{ea=H}]] This fixes the remaining 24 line break tests. Task-number: QTBUG-97537 Pick-to: 6.3 Change-Id: I9870588c04bf0f6ae0a98289739bef8490f67f69 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QUnicodeTools: Fix line breaking for potential emojisIevgenii Meshcheriakov2022-05-241-1/+1
| | | | | | | | | | | | | | Implement part of LB30b introduced by UAX #14, revision 47 (Unicode 14.0.0): [\p{Extended_Pictographic}&\p{Cn}] × EM This fixes one line breaking test. Task-number: QTBUG-97537 Pick-to: 6.3 Change-Id: I3fd2372a057b7391d8846e9c146f69a54686ea61 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QUnicodeTools: Fix interactions of WB3d and WB4 rulesIevgenii Meshcheriakov2022-05-241-1/+1
| | | | | | | | | | | Word breaking rule WB3d should not be affected by WB4. This fixes the remaining word break test. Task-number: QTBUG-97537 Pick-to: 6.2 6.3 Change-Id: I99aee831d7c54fafcd2a9d526a3e078b12c5bfad Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QUnicodeTools: Handle WB3c word break ruleIevgenii Meshcheriakov2022-05-241-9/+9
| | | | | | | | | | | | | | | Adjust handling of WB3c rule to UAX #29, revision 33 (Unicode 11.0.0). The rule reads: ZWJ × \p{Extended_Pictographic} This fixes 9 word break tests. Task-number: QTBUG-97537 Pick-to: 6.2 6.3 Change-Id: I818d4048828e6663d5c090aa372d83f5099fdffe Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QUnicodeTools: Adjust properties of WSegSpace word break classIevgenii Meshcheriakov2022-05-242-37/+37
| | | | | | | | | | | | | | | | | | Disable break between sequences of WSegSpace characters (rule WB3d, introduced in UAX #29, version 33, Unicode 11.0.0). Also disable breaks between WSegSpace and (Extend | Format | ZWJ) due to rule WB4. Adjust "words4" test to take the above changes into account (space character belongs to WSegSpace). Mention the full class name in a comment inside the word break table. This fixes 34 word break tests. Task-number: QTBUG-97537 Pick-to: 6.2 6.3 Change-Id: I7dfe8367e45c86913bb7d7fe2adb053711978487 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QUnicodeTools: Fix handling of LB22 line break ruleIevgenii Meshcheriakov2022-05-241-28/+28
| | | | | | | | | | | | | | This rule was simplified in version UTS #14 version 45 (Unicode 13.0.0) to read: × IN Re-enabled 28 fixed line break tests. Task-number: QTBUG-97537 Pick-to: 6.2 6.3 Change-Id: I1c5565a8c1633428c22379917215d4e424ff0055 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QUnicodeTools: Fix handling of ZWJ for line breaksIevgenii Meshcheriakov2022-05-241-9/+9
| | | | | | | | | | | | | | | Adjust implementation of rule LB8a of UAX #14. The rule was changed in version 41 (corresponding to Unicode 11.0.0): ZWJ × (ID | EB | EM) ⇒ ZWJ × Fixing this rule fixes 9 line break tests. Those are re-enabled. Task-number: QTBUG-97537 Pick-to: 6.2 6.3 Change-Id: I1570719590a46ae28c98ed7d5053e72b12915db7 Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tst_QStringConverter: roll up independent tests to rows in othersThiago Macieira2022-05-231-59/+6
| | | | | | | | | Simplifies the test a little. Pick-to: 6.3 Change-Id: I77c8221eb2824c369feffffd16f0a7fc44215aaf Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* tst_QStringConverter: implement the TODO of testing with flagsThiago Macieira2022-05-231-4/+81
| | | | | | Pick-to: 6.3 Change-Id: I77c8221eb2824c369feffffd16f0a7e428b23fb6 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* tst_QStringConverter: improve the char-by-char UTF-8 testingThiago Macieira2022-05-233-63/+168
| | | | | | | | | | | | | | The utf8.txt file was only 21 bytes and contained exactly two non-ASCII characters. It wasn't very good. This commit brings back the UTF-8 test rows that existed before commit 18ec53156ee704fdb4977436fccfdc85333e614b deleted tst_Utf8. There's a lot of overlap with some of the other rows in this test, though. Pick-to: 6.2 6.3 Change-Id: I77c8221eb2824c369feffffd16f094619b69faef Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QStringConverter: use the QUtf8 codec when Windows is using UTF-8Thiago Macieira2022-05-231-14/+50
| | | | | | | | | | | | | | | | | | | | The QLocal8Bit implementation assumes that there's at most one continuation byte -- that is, that all codecs are either Single or Double Byte Character Sets (SBCS or DBCS). It appears to be the case for all Windows default codepages, except for CP_UTF8, which is an opt-in anyway. Instead of fixing our codec, let's just use the optimized UTF-8 implementation. [ChangeLog][Windows] Fixed support for using Qt applications with UTF-8 as the system codepage or by enabling that in the application's manifest. Discussed-on: https://lists.qt-project.org/pipermail/interest/2022-May/038241.html Pick-to: 6.2 6.3 Change-Id: I77c8221eb2824c369feffffd16f0912550a98049 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Android: Enable building of the QLocale test caseVolker Hilsheimer2022-05-231-4/+1
| | | | | | | | | | | Amends 2a893db48017a850044156442b93d935c78e941d, which changed the #ifdef'ery but didn't actually enable the building of the test on Android. Task-number: QTBUG-87414 Pick-to: 6.3 6.2 Change-Id: Id944dd3023da40ecbf4b8a324784409a63f94aec Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* 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>