summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
Commit message (Collapse)AuthorAgeFilesLines
...
* Teach QLocale::system() to use narrow formatIvan Solovev2021-09-151-0/+27
| | | | | | | | | | | | | | | | QLocale::system() was not making use of QLocaleFormat::Narrow, always treating it in the same way as QLocaleFormat::Short. This patch fixes the issue for day and month names. The implementation falls back to CLDR if system locale fails to provide some data. Pick-to: 6.2 Task-number: QTBUG-84877 Change-Id: Ia37e59dbf02d7a5e230f2767d294b9ab7de37f33 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Tidy up #includes in tst_qlocale.cppEdward Welbourne2021-09-141-17/+15
| | | | | | | | System headers were jumbled in with Qt headers. Separate those out and use standard names for Qt headers. Tidied some #if-ery. Change-Id: Ic8c61797303567eeaef48e2560e91924ddb380f0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Move locale-switching code in tests to a shared headerEdward Welbourne2021-09-142-66/+6
| | | | | | | | | | | | | | | | | | | | | | QLocale and QString tests had copies of a TransientLocale; we've recently improved the QLocale one. Rather than duplicating those rather complicated improvements, finally share a common version. In the process, I noticed that setlocale() only returns the prior value when passed nullptr as the new value; so rework the implementation to get that right, so that it now correctly restores the prior locale. That, in turn, means there's now a later call to setlocale(), when we actually set the changed setting, which may invalidate the earlier return; so copy it to a QByteArray before the second call. Included Ivan Solovev's improved version of how to reset the locale, since TransientLocale needs it. Pick-to: 6.2 Change-Id: I4cb1efbda42f0e2cdd934e04b3b3732ce0f45a06 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QPlugin/QFactoryLoader: remove Qt 5 plugin remnantsThiago Macieira2021-09-141-37/+0
| | | | | | | | | | | Qt 6.x does not need to be able to read the old Qt 5-based binary JSON metadata. The QT_WARNING_DISABLE_DEPRECATED was needed in 5.15 while we used the then-deprecated functions to decode. Pick-to: 6.2 Change-Id: I2de1b4dfacd443148279fffd16a39ee074da3ef4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Re-enable tst_qplugin on LinuxThiago Macieira2021-09-141-6/+1
| | | | | | | | It was disabled during the CMake port, but appears to work now. Change-Id: I2de1b4dfacd443148279fffd16a3a166a3e10671 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* feat: add new interfaces for std::filesystem::pathJiDe Zhang2021-09-141-0/+18
| | | | | | | | | Add for QFile::exists/symLinkTarget/remove/moveToTrash/ rename/link/copy Change-Id: I4cbb908e945f043b2a5278a6d8d5149b2f20e871 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Skip tst_QReadWriteLock::multipleReadersLoop on QEMUSona Kurazyan2021-09-092-0/+5
| | | | | | | | | | The test is randomly failing in the CI on QEMU. Couldn't reproduce it on the actual armv7 hardware, so most likely it's not a Qt bug. Fixes: QTBUG-96103 Pick-to: 6.1 6.2 Change-Id: I60b7264c6ce44b3b327fdd0dbcede006717c65a6 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tst_qstringapisymmetry: Don't pretend that QByteArray contains UTF-8Ievgenii Meshcheriakov2021-09-091-10/+8
| | | | | | | | | | | | | | | | | | The name of is_utf8_encoded type seems to imply that QByteArray and const char * contain UTF-8 encoded data. This is not always the case. When used with QByteArray API, those types are handled as containing ASCII-only. It's only when used with APIs of other classes (QString, QLatin1String) they are handled as UTF-8. This renames the check to is_bytearray_like_v and clarifies its usage. No need to handle QUtf8StringView this way because it works just fine with the current testcases. While at it, also remove unused is_latin1_encoded trait. Task-number: QTBUG-92021 Change-Id: I44e40cf3c0dd07e5b3cf1e47ff7a04f1c548aa97 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add new am/pm format-specifier that preserves locale's caseEdward Welbourne2021-09-082-6/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The existing a, ap, A and AP specifiers all force the case of the formatted am/pm indicator. The indicators returned by QLocale's amText() and pmText() methods are those given in CLDR, with no case coercion. Application writers may reasonably want these strings used verbatim, rather than having to chose a case and impose it on the locale's indicators, in defiance of national custom. For example, while en_US uses upper-case indicators by default, cs_CZ uses lower-case ones. An application author writing a time format has been forced to chose which of these locales to be wrong in. Add support for aP and Ap specifiers, whose mixed case indicates that the locale's case is to be respected. Amend an existing test-case of tst_QLocale's formatDateTime() that used Ap (expecting, of course, an upper-case indicator followed by a stray p) to now expect the locale-appropriate-cased indicator. Extend formatTime() to test cases using aP and Ap, to illustrate the difference between en_US and cs_CZ. Rework QDateTimeParser to also support the new format specifier. This required expanding its Case enum, used by the getAmPmText() method, which was formerly shared with QDateTimeEditPrivate; however, as that class no longer makes any reference to this method, it and the enum can be made private, allowing a systematic clean-up of their use. Added test-cases for both serialization and parsing; and amended some existing parsing tests to verify am/pm indicators are matched case-insensitively. [ChangeLog][QtCore][Important Behavior Changes] Time formats used by QLocale, QTime and QDateTime's parsing and serialization now recognize 'aP' and 'Ap' format specifiers to obtain an AM/PM indicator, using the locale-appropriate case for the indicator, where previously the author of a time format had to pick a case that might conflict with the user's locale. For QTime and QDateTime the locale is always C, whose indicators are uppercase. For QLocale, the case will now match that of amText() or pmText(). Previously, 'aP' would have been read as a lower-case indicator followed by a 'P' and 'Ap' as an upper-case indicator followed by a 'p'. The 'P' or 'p' will now be treated as part of the format specifier: if the prior behavior is desired, either use 'APp' or 'apP' as format specifier or quote the 'p' or 'P' in the format. The prior 'a', 'ap', 'A' and 'AP' specifiers are otherwise unaffected. Fixes: QTBUG-95790 Change-Id: I26603f70f068e132b5c6aa63214ac8c1774ec913 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Q_DECLARE_INTERFACE: delete unspecialized qobject_interface_iid()Thiago Macieira2021-09-071-2/+0
| | | | | | | | Instead of making it return a non-useful nullptr. Change-Id: Ie72b0dd0fbe84d2caae0fffd16a245cce5ea65f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix compilation for recursive Qt containersSona Kurazyan2021-09-071-0/+144
| | | | | | | | | | | | | | | | | | | | The operator checks cause compilation errors when trying to check for their existence for recursive containers. This happens because of trying to check for the operators on the template parameter type(s), that inherit from the container itself, which leads to compilation errors. Introduced alternative versions of the operator checks (with _container suffix), that first check if the container is recursive, i.e. any of its template parameter types inherits from the given container, and skips the operator check, if that's the case. The fix is done for all Qt container types that had the problem, except for QVarLengthArray and QContiguousCache, which don't compile with recursive parameter types for unrelated reasons. Fixes: QTBUG-91707 Pick-to: 6.2 6.1 Change-Id: Ia1e7240b4ce240c1c44f00ca680717d182df7550 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_QtJson: add matching escape-generating testThiago Macieira2021-09-061-0/+55
| | | | | | | Change-Id: Ie72b0dd0fbe84d2caae0fffd16a11596eb61a90e Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* JSON parsing: fix incorrect sign-extension for decoding bad escapesThiago Macieira2021-09-061-7/+64
| | | | | | | | | | | | | | The parser was lenient in accepting backslashes followed by invalid characters, but accidentally sign-extended everything above 0x7f causing broken outputs that weren't valid UTF-16 either. For example, the sequence "\\\xff" (backslash followed by 0xff) produced sequence "\ud7bf\udfff" (U+D7BF is not a surogate pair). Change-Id: Ie72b0dd0fbe84d2caae0fffd16a113c703a7696f Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix QLocale::system() standalone day and month handlingIvan Solovev2021-09-061-0/+127
| | | | | | | | | | | | | | | Some backends were missing support for standalone days and months, also the standaloneDayName() implementation was always using the same codepath as dayName(). This patch fixes the issues. Support for narrow format will be added in the following patch. Task-number: QTBUG-84877 Pick-to: 6.2 Change-Id: I38ee06342cafab544e3c69097bd0e6ae68e85645 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Make tst_QLocale::TransientLocale succeed at changing system localeIvan Solovev2021-09-031-2/+46
| | | | | | | | | | | | | | | | It was previously calling setlocale(), which makes no difference to the Unix backend for the system locale, since that's based on environment variables (that would normally be used to get default values for the various setlocale() categories, but only the first time each is asked for). So, on Unix, set the environment variable, too. It's also necessary to instantiate a QSystemLocale instance transiently to trigger a refresh of the system locale data. Pick-to: 6.2 Change-Id: If92e44053f9021e96c814f4b289f4fadaa7027e0 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* qstrnlen: micro-optimize furtherThiago Macieira2021-09-011-7/+7
| | | | | | | | | | | | This is the kind of loop that the autovectorizer is pretty good at, but this is really just a type of memchr, so help dumber compilers and build modes without vectorization. Drive-up fix the style of the test code. Change-Id: Ie72b0dd0fbe84d2caae0fffd16a022a35fa24c17 Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* qlocale_win: Fix non-standalone month namesEdward Welbourne2021-09-011-3/+10
| | | | | | | | | | | | | | | | | | | | We have previously been using the standalong (nominative) month names both when asked for that and when asked for the plain (genitive) month name, probably because there was no LCTYPE value for the latter. However, MS's docs for the standalone values do contain a comment telling us how to get the genitive names. Rename the old monthName() to standaloneMonthName() and add a monthName() that calls GetDateFormat() suitably, as described by the MS doc. Pick-to: 6.2 5.15 Fixes: QTBUG-92018 Fixes: QTBUG-86279 Change-Id: I27f63198c3a15b792683f476d2019078b0860f99 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* tests: Add test for UTS #46 implementation using Unicode dataIevgenii Meshcheriakov2021-09-014-0/+6506
| | | | | | | | | | | | The new test is called tst_qurluts46. It verifies QUrl::{to,from}Ace() functionality using the data from IdnaTestV2.txt supplied by Unicode. The file was downloaded from https://www.unicode.org/Public/idna/13.0.0/IdnaTestV2.txt Task-Id: QTBUG-85371 Change-Id: I4c6a4942ef6018dafc90cb84ef73f6b2614566d7 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tst_qstringapisymmetry: Re-enable trim_trimmed_QByteArrayIevgenii Meshcheriakov2021-08-311-1/+1
| | | | | | | | | The testcase was disabled with no explanation in 2766322de37adba37e0d0d4b0054e55edff01c6c but seems to work fine. Change-Id: Ibc22a4ffb756604e22c1f2cf1165919c1d7f1212 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Teach QByteArrayView how to parse numbersEdward Welbourne2021-08-302-574/+660
| | | | | | | | | | | | Now that we don't need '\0'-termination on the data, this is possible. Moved QByteArray's tests to tst_QByteArrayApiSymmetry and added some more test-cases. [ChangeLog][QtCore][QByteArrayView] Added numeric parsing methods. Change-Id: Ic0df91ecfe5dbf6f008d344dd0464d7927f32273 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Replace FreeBSD's strtou?ll() with std::from_chars()-based strntou?ll()Edward Welbourne2021-08-303-20/+258
| | | | | | | | | | | | | | | Remove third-party code in favor of STL. Implement (for now) strtou?ll() as inlines on strntou?ll() calling strlen() for the size parameter. (This is not entirely safe, as a string lacking '\0'-termination but with at least some non-matching text after the numeric portion would formerly be parsed just fine, but would now produce a crash. However, strtou?ll() are internal and callers should be ensuring '\0'-termination.) Task-number: QTBUG-74286 Change-Id: I0c8ca7d4f6110367e93b4c0164854a82c5a545e1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QObject::connect(): fail to connect to a functor if UniqueConnection is passedGiuseppe D'Angelo2021-08-271-2/+3
| | | | | | | | | | | | | | | | | | | | | The connect() documentation makes it clear that UniqueConnection does not work with free functions / function objects and the like; only with actual PMFs. Rather than silently *ignoring* the flag, be vocal about its presence by warning, and make the connection fail (as the user has passed an illegal argument). [ChangeLog][QtCore][QObject] QObject::connect() now will refuse to connect a signal to a free function / function object if UniqueConnection is passed. Note that UniqueConnection has never worked for such connections -- the flag was simply ignored, and they were established multiple times. Now, the flag is not ignored and results in a connection failure (as well as a runtime warning by Qt). Change-Id: I6509667018c74f9bd24910cde0a1b16c5f84f064 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QBA(V)/QS(V)::lastIndexOf: fix the search of 1-char needlesGiuseppe D'Angelo2021-08-262-4/+4
| | | | | | | | | | | | | | | | | | | | When a needle has length 1 (because it's a QChar/char16_t, or because it's a string-like of length 1) then an ad-hoc search algorithm is used. This algorithm had a off-by-one, by not allowing to match at the last position of a haystack (in case `from` was `haystack.size()`). That is inconsistent with the general search of substring needles (and what QByteArray does). Fix that case and amend wrong tests. This in turn unveiled the fact that the algorithm was unable to cope with 0-length haystacks (whops), so fix that as well. Drive-by, add a similar fix for QByteArray. Amends 6cee204d56205e250b0675c9c6d4dd8a2367f3c4. Pick-to: 6.2 Change-Id: I6b3effc4ecd74bcbcd33dd2e550da2df7bf05ae3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tst_qurl{,internal}: Use U+FB01 for normalization to ASCII test casesIevgenii Meshcheriakov2021-08-252-4/+6
| | | | | | | | | | | | Use U+FB01 LATIN SMALL LIGATURE FI instead of U+00DF LATIN SMALL LETTER SHARP S in testcases that need non-ASCII URLs that are normalized to ASCII. The latter is not normalized to ASCII when using UTS #46 nontransitional processing. Task-number: QTBUG-85371 Change-Id: I8c153feb58e556b1d31439018cc84d8e8f1de1a7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tst_qurlinternal: Remove testcases that use U+04CFIevgenii Meshcheriakov2021-08-251-6/+0
| | | | | | | | | | U+04CF CYRILLIC SMALL LETTER PALOCHKA was undefined in Unicode 3.5 used by IDNA2003 but it is allowed in UTS #46. Task-number: QTBUG-85371 Change-Id: I7f5c0f6dc57f1197fd509e98328207d6179f1624 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tst_qurlinternal: Remove nameprep and STD3 rules testsIevgenii Meshcheriakov2021-08-251-325/+0
| | | | | | | | | | | | IDNA 2008/UTS #46 do not use nameprep anymore and have different validity rules. Unexport qt_nameprep() and qt_check_std3rules() because they are not used by any tests anymore. Task-number: QTBUG-85323 Change-Id: I38c0dbae9a6bd108fbcfac350767aa7e757e786f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_qurl: Make an invalid URL test compatible with UTS #46Ievgenii Meshcheriakov2021-08-251-3/+4
| | | | | | | | | | | Use U+1F100 DIGIT ZERO FULL STOP instead of U+1F4D9 ORANGE BOOK. The latter is not allowed according to IDNA 2003 rules but is allowed according to UTS #46 rules. The former is disallowed in either case. Task-number: QTBUG-85371 Change-Id: Idc8afef68c26ae0b702a475e5a53592182998a08 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QRegularExpressionMatch: add a way to know if a capturing group capturedGiuseppe D'Angelo2021-08-251-79/+159
| | | | | | | | | | | | | | | | | | | | | | | Relying on the fact that a given capturing group captured a null string doesn't allow users to distinguish whether a capturing group did not capture anything, or captured a null substring (say, from a null subject string). Perl allows for the distinction: the entries in the @- and @+ arrays are set to values in case there is a capture, but they're undef otherwise. PCRE2 gives us the information already in the results "ovector", but it was simply not exposed to QREM users. So, expose it. [ChangeLog][QtCore][QRegularExpressionMatch] Added the hasCaptured() family of functions to know if a given capturing group has captured something. Change-Id: Ic1320933d4554e2e313c0a680be1b1b9dd95af0b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Revive tst_qresourceengineJoerg Bornemann2021-08-245-3/+68
| | | | | | | | | | This test was not ported to CMake yet. Pick-to: 6.2 Fixes: QTBUG-88601 Change-Id: Ied3b1a0e2ddfbcf003cb0d8d01d5f64cb83cf4e7 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Unicode: fix the grapheme clustering algorithmGiuseppe D'Angelo2021-08-241-0/+101
| | | | | | | | | | | | | | | | | | | An oversight in the code kept the algorithm in the GB11 state, even if the codepoint that is being processed wouldn't allow for that (for instance a sequence of ExtPic, Ext and Any). Refactor the code of GB11/GB12/GB13 to deal with code points that break the sequences (falling back to "normal" handling). Add some manual tests; interestingly enough, the failing cases are not covered by Unicode's tests, as we now pass the entire test suite. Amends a794c5e287381bd056008b20ae55f9b1e0acf138. Fixes: QTBUG-94951 Pick-to: 6.1 5.15 Change-Id: If987d5ccf7c6b13de36d049b1b3d88a3c4b6dd00 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use constexpr for constants and ranged-based for loopsEdward Welbourne2021-08-231-99/+89
| | | | | | | | | In the process, actually use the constants as the size of some arrays, instead of making [1024] arrays and then only using a few entries. Change-Id: I9f36b322840393b8680788190cf8b40a828f4957 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Re-add QPropertyAlias functionalityFabian Kosmale2021-08-231-0/+17
| | | | | | | | | | | | | | | | | As QPropertyAlias was public by accident in 6.0, we have to ensure that it still works in 6.2. This re-adds some tests for it, and reimplements the unlinking functionality. To avoid performance regressions in hot-paths, a new unlink_fast function is added, which behaves like the old unlink: It ignores the special handling for QPropertyAlias, so that we can skip the tag check. It is only used in QPropertyObserverNodeProtector and clearDependencyObservers, where we already know the type of the observer. Fixes: QTBUG-95846 Pick-to: 6.2 Change-Id: Ifb405b8327c4d61c673b1a912ed6e169d27c2d8f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* tst_QPluginLoader: Simplify creating a fake pointer in fakeplugin.cppMartin Storsjö2021-08-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When assigning multiple variables to a specific section, both GCC and Clang legitimately error out if those variables wouldn't end up in the same section (e.g. if one of them is going to a read-only section while the other one is going to a read-write section). In C++, when a seemingly const variable needs dynamic initialization, it needs to be stored in a read-write section. Clang 13 changed internals for how some constants are materialized. Now, when a variable is initialized with an expression containing plain old fashioned casts, it is considered to be potentially runtime initialized (at the point when section assignment conflicts is evaluated). Therefore, Clang 13 errors out on fakeplugin.cpp with errors like: fakeplugin.cpp:36:39: error: 'message' causes a section type conflict with 'pluginSection' QT_PLUGIN_METADATA_SECTION const char message[] = "QTMETADATA"; ^ fakeplugin.cpp:32:40: note: declared here QT_PLUGIN_METADATA_SECTION void *const pluginSection = (void*)(0xc0ffeec0ffeeL); ^ See https://bugs.llvm.org/show_bug.cgi?id=51442 for discussion on the matter in Clang. To simplify things, just initialize the fake pointers as regular uintptr_t instead, avoiding the whole matter. This produces the exact same contents in the section as before. For what it's worth, the actual manually constructed metadata in fakeplugin.cpp doesn't seem to have any effect on running the QPluginLoader tests on either ELF or MachO right now. Change-Id: Ib84a2ceb20cb8e3a1bb5132a5715538e08049616 Pick-to: 6.2 6.1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Improve and simplify tst_QByteArray's testsEdward Welbourne2021-08-191-76/+69
| | | | | | | | | | | | Don't go via QString when we don't need to. Put expected after actual, not the other way round. Give tests and test-cases sensible names. Prefer function-style cast over C-style. Change-Id: I0b79534a9cc95f2e312a85394693ac674ff3d1d6 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QString: use the QRegularExpression operations on QStringViewGiuseppe D'Angelo2021-08-191-10/+10
| | | | | | | | | | | | | | | | There's no need of duplicating code all over the place; QString can reuse the implementation of the indexOf/contains/count/lastIndexOf family of functions already existing for QStringView. For simplicity, the warning messages (that our autotests actually check) have been made more generic, rather than introducing some other parameter (as in, "which class is using this functionality so to emit a more precise warning"), which would have just complicated things as the implementation of these functions is exported and used by inline QStringView member functions. Change-Id: I85cd94a31c82b00d61341b3058b954749a2d6c6b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QRegularExpression: fix matching over null/empty QString(View)Giuseppe D'Angelo2021-08-191-2/+23
| | | | | | | | | | | | | | | | | | | | | | | An empty QString(View) is allowed to have nullptr as its data pointer (of course, only if its size is 0). This wasn't properly checked in QRegularExpression, which passed such nullptr to PCRE, and that resulted in PCRE raising an error (PCRE_ERROR_NULL). Detect this case and pass a dummy pointer to keep PCRE happy. Fixing and testing this in turn exposed a problem with QStringView support in QRegularExpression when used over a null QString: the code is supposed to use the QStringView(QString) constructor and NOT qToStringViewIgnoringNull. That's because QRE distinguishes null and empty subjects; when using qToStringViewIgnoringNull over a null QString, one gets a non-null QStringView (!). Again, this in turn exposed a problem with a QRegularExpression autotest that assumed that a null match could only mean "no match" (instead, it can happen at position 0 of a null QString(View)). Change-Id: Ifb3cf14dec42ce76fcdbcb07ea1d80784d52ef65 Pick-to: 6.1 6.2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QS(V)/QBA(V)/QL1S::lastIndexOf: fix the offset calculationsGiuseppe D'Angelo2021-08-194-22/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When trying to fix 0-length matches at the end of a QString, be83ff65c424cff1036e7da19d6175826d9f7ed9 actually introduced a regression due to how lastIndexOf interprets its `from` parameter. The "established" (=legacy) interpretation of a negative `from` is that it is supposed to indicate that we want the last match at offset `from + size()`. With the default from of -1, that means we want a match starting at most at position `size() - 1` inclusive, i.e. *at* the last position in the string. The aforementioned commit changed that, by allowing a match at position `size()` instead, and this behavioral change broke code. The problem the commit tried to fix was that empty matches *are* allowed to happen at position size(): the last match of regexp // inside the string "test" is indeed at position 4 (the regexp matches 5 times). Changing the meaning of negative from to include that last position (in general: to include position `from+size()+1` as the last valid matching position, in case of a negative `from`) has unfortunately broken client code. Therefore, we need to revert it. This patch does that, adapting the tests as necessary (drive-by: a broken #undef is removed). Reverting the patch however is not sufficient. What we are facing here is an historical API mistake that forces the default `from` (-1) to *skip* the truly last possible match; the mistake is that thre is simply no way to pass a negative `from` and obtain that match. This means that the revert will now cause code like this: str.lastIndexOf(QRE("")); // `from` defaulted to -1 NOT to return str.size(), which is counter-intuitive and wrong. Other APIs expose this inconsistency: for instance, using QRegularExpressionIterator would actually yield a last match at position str.size(). Similarly, using QString::count would return `str.size()+1`. Note that, in general, it's still possible for clients to call str.lastIndexOf(~~~, str.size()) to get the "truly last" match. This patch also tries to fix this case ("have our cake and eat it"). First and foremost, a couple of bugs in QByteArray and QString code are fixed (when dealing with 0-length needles). Second, a lastIndexOf overload is added. One overload is the "legacy" one, that will honor the pre-existing semantics of negative `from`. The new overload does NOT take a `from` parameter at all, and will actually match from the truly end (by simply calling `lastIndexOf(~~~, size())` internally). These overloads are offered for all the existing lastIndexOf() overloads, not only the ones taking QRE. This means that code simply using `lastIndexOf` without any `from` parameter get the "correct" behavior for 0-length matches, and code that specifies one gets the legacy behavior. Matches of length > 0 are not affected anyways, as they can't match at position size(). [ChangeLog][Important Behavior Changes] A regression in the behavior of the lastIndexOf() function on text-related containers and views (QString, QStringView, QByteArray, QByteArrayView, QLatin1String) has been fixed, and the behavior made consistent and more in line with user expectations. When lastIndexOf() is invoked with a negative `from` position, the last match has now to start at the last character in the container/view (before, it was at the position *past* the last character). This makes a difference when using lastIndexOf() with a needle that has 0 length (for instance an empty string, a regular expression that can match 0 characters, and so on); any other case is unaffected. To retrieve the "truly last" match, one can pass a positive `from` offset to lastIndexOf() (basically, pass `size()` as the `from` parameter). To make calls such as `text.lastIndexOf(~~~);`, that do not pass any `from` parameter, behave properly, a new lastIndexOf() overload has been added to all the text containers/views. This overload does not take a `from` parameter at all, and will search starting from one character past the end of the text, therefore returning a correct result when used with needles that may yield 0-length matches. Client code may need to be recompiled in order to use this new overload. Conversely, client code that needs to skip the "truly last" match now needs to pass -1 as the `from` parameter instead of relying on the default. Change-Id: I5e92bdcf1a57c2c3cca97b6adccf0883d00a92e5 Fixes: QTBUG-94215 Pick-to: 6.2 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tst_QLocale::formatTime(): add some actual locale-dependenceEdward Welbourne2021-08-181-43/+68
| | | | | | | | | | | All the tests were using the C locale, so were equivalent to tests of QTime::toString(). Add a locale column and some test-cases in preparation for a change to am/pm indicators. Task-number: QTBUG-95790 Change-Id: I3ad917b7a6f3d3bfe31d6a5a5da596025f173e81 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtConcurrent::run: support non default-constructible return typesSona Kurazyan2021-08-181-4/+4
| | | | | | | | | | | | | | The QtConcurrent::RunFunctionTask class keeps a variable to store the result of QtConcurrent::run when it becomes available, so that it can be reported afterwards. This requires the result type to be default-constructible. However there's no need in storing the result, it can be reported immediately after it becomes available. Pick-to: 6.1 6.2 Fixes: QTBUG-95214 Change-Id: I95f3dbff0ab41eaa81b104a8834b37d10a0d193a Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Use a scope-guard to take care of process deletion in a testEdward Welbourne2021-08-171-6/+5
| | | | | | | | | | Doing the deletion at the end of the block only works if the test passes. Drive-by: remove spurious braces from single-line bodies of single-line controls. The QTest macros are done properly. Pick-to: 6.2 6.1 5.15 Change-Id: I83002547dba49ab9792f4db44d73151b1c036900 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Attempt to unwedge tst_QThread::wait3_slowDestructor()Edward Welbourne2021-08-171-13/+15
| | | | | | | | | | | | | | | | When the test failed, it never released the blocking slot, so the tested thread remained blocked indefinitely. Blacklisting doesn't rescue that: the test run gets killed by Coin's watchdog. Use a QScopeGuard() to release the clocked slot on failure. replacing the release that was happening only on success. As drive-by clean-up, smarten up the code a little and remove an unused enum. Pick-to: 6.2 6.1 5.15 Change-Id: Ie035dafe6e4b1d82aea5de38ceb31c0f7fcf81d7 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* tests: Remove unused SRCDIR definesIevgenii Meshcheriakov2021-08-176-12/+0
| | | | | | | | | | | Remove SRCDIR defines from tests that don't use them. There is a standard define called QT_TESTCASE_SOURCEDIR that is available to all tests and serves the same purpose. Pick-to: 6.2 Change-Id: I2aa237739c011495e31641cca525dc0eeef3c870 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* QString/QByteArray::number(double): Test big numbersMårten Nordheim2021-08-173-3/+42
| | | | | | | | | | | Exhausts the entire buffer which double-conversion is left to work with. Also has a large amount of precision, which apparently we need to store temporarily. Task-number: QTBUG-88484 Change-Id: I87e8c323676465f1b8695e086020df1240d0d0d7 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUrl: Improve Punycode overflow handlingIevgenii Meshcheriakov2021-08-161-2/+0
| | | | | | | | | | | | | | | | | | | | Add more overflow checks from the sample code in RFC 3492. Also check if a code point to be inserted into output is in the allowable range for Unicode. Rewrite all overflow checks to use {add,mul}_overflow() functions. Do not try to process any inputs that are too long to be part of a valid domain name label. This fixes a test in tst_qurlinternal. Fixes: QTBUG-95689 Pick-to: 6.2 Change-Id: Ice0b3cd640d8a688b63a791192ef2fa2f13444be Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QVarLengthArray: add support for emplacementMarc Mutz2021-08-161-0/+19
| | | | | | | | | | | | | Take the rvalue insert() function and turn it into the emplace() function. Reformulate rvalue-insert using emplace(). Lvalue insert() is using a different code path, so leave that alone. This way, we don't need to go overboard with testing. [ChangeLog][QtCore][QVarLengthArray] Added emplace(), emplace_back(). Change-Id: I3e1400820ae0dd1fe87fd4b4c518f7f40be39f8b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Add QByteArrayView::trimmed()Edward Welbourne2021-08-113-29/+39
| | | | | | | | | | | | Unlike simplified(), it just moves the end-points, without needing to modify contents, so it makes sense (as for QStringView and QLatin1String) to provide it. Moved QByteArray's trimmed() tests to tst_QByteArrayApiSymmetry so that QBAV can now share them. [ChangeLog][QtCore][QByteArrayView] Added trimmed(). Change-Id: Ifd7a752adb5f3d3e2ad0aa8220efa7e7d2d39baa Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QUrl: Fix handling of invalid sequences starting with xn--Ievgenii Meshcheriakov2021-08-111-1/+0
| | | | | | | | | | | | | | Return ASCII sequences that start with xn-- but fail Punycode decoding as is when converting URLs to Unicode. This is consistent with handling of sequences that do decode successfully but fail other validity checks. This fixes one test in tst_qurlinternal. Task-number: QTBUG-95689 Pick-to: 6.2 Change-Id: I63d7197f25102c96f5dc21d9fecec5e015c531cb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_qurlinternal: Add another Punycode overflow testIevgenii Meshcheriakov2021-08-111-0/+4
| | | | | | | | | | | The test string "xn--l0902716a" encodes 2**32. Currently the IDNA code returns an empty string when encoding this to Unicode instead of expected original string. Task-number: QTBUG-95689 Pick-to: 6.2 Change-Id: I5ce7bcc744c9d5426f66b8a7d0ae76c7c92f552b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tst_qurlinternal: Use a lambda for bad IDN testsIevgenii Meshcheriakov2021-08-101-15/+13
| | | | | | | | | Use a lambda to simplify testcases for bad IDNs. Task-number: QTBUG-95689 Pick-to: 6.2 Change-Id: Ia4f3a5dbc73c74968628d89bd64d7aa6692b1c46 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Assert that special handling of '0' padding does what it shouldEdward Welbourne2021-08-101-21/+61
| | | | | | | | | | | | | | | | | | | | When formatting numbers, if the fill character used to left-pad to field widths is '0', the code delegates that padding to the QLocaleData's ZeroPadded formatting option. Since we want the zeros before any minus sign, and don't want to subsequently add more zeros before it, check that this has worked as expected when calling replaceArgEscapes(), to confirm that it doesn't need to worry about that. Add some tests that verify the expected behavior. In the process, tidy up the code doing this. Rename a local variable to match our coding style, split a long line. Pick-to: 6.2 Change-Id: I7cc430c5bceb006cf4e226bca33da16bd2bb1937 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>