Commit Graph

5072 Commits

Author SHA1 Message Date
Ievgenii Meshcheriakov
9a3f4afb70 Remove checks for features available in C++17
This patch removes most of the checks that are made using C++20
__cpp_* macros for features available in C++17 and earlier.
Library feature check macros (__cpp_lib_*) are unaffected.

Change-Id: I557b2bd0d4ff09b13837555e9880eb28e0355f64
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-10-02 17:54:39 +02:00
David Faure
8652f4766b Untangle qsortfilterproxymodel unittests
With the QRegExp variant removed, it was weird to have all QSFPM
tests in "tst_qsortfilterproxymodel_regularexpression", even those
completely unrelated to regexps. Instead of reuniting into a single
executable as before, I simply split it out in separate executables:

* tst_qsortfilterproxymodel has the "standard" QSFPM tests
* tst_qsortfilterproxymodel_regularexpression has the regexp-related tests
* tst_qsortfilterproxymodel_recursive is separate as before

Change-Id: I345530b4352671164008bba4805af7b12ac90247
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-10-01 18:30:25 +02:00
Allan Sandfeld Jensen
9a6c653eaf Cleanup of qthreadpool
Don't bother overwaiting in waitForDone(), if it was done at one point
after it was called we can return true. And do not stop threads recently
awakened by a startThread call as they have tasks to do.

Make allowing at least one thread regardless of reservation more
standard instead of hacked in certain places.

Pick-to: 6.2
Change-Id: I304bcdc5822f440d5e72fc33ba2aa1678c9ba0d0
Reviewed-by: David Faure <david.faure@kdab.com>
2021-10-01 12:01:21 +02:00
Ievgenii Meshcheriakov
49d94bbb41 Assume that <variant> header is always present
This header is a C++17 feature that is already used unconditionally
in qtypeinfo.h.

Change-Id: I26330d298e95102f3e94c0c69fc95c1025666eb4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-10-01 02:46:27 +02:00
Ievgenii Meshcheriakov
e0b87edd73 tst_qthread: Don't use QVERIFY in multiple threads in threadIdReuse()
Testlib is not thread safe. Store the status into variable and check
it in the main thread instead.

Pick-to: 6.2
Change-Id: I840c8a3dceb1115a1b81ffeaa0fab96f9d2f1ff0
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-10-01 02:46:17 +02:00
Ievgenii Meshcheriakov
44a7412795 Remove checks for C++ standard versions C++17 and below
Qt requires a compiler that support C++17 thus __cplusplus
is always 201703L or higher. This patch removes checks
for __cplusplus value that always succeed.

Change-Id: I4b830683ecefab8f913d8b09604086d53209d2e3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-10-01 02:46:09 +02:00
Karsten Heimrich
55ab987c9a Fix QDir::entryList to work for directories that end with '.lnk'
In addition to checking the .lnk extension, check that the
the specified path is not a path to a directory.

Pick-to: 6.2
Fixes: QTBUG-85058
Change-Id: I83cef3d94c6ffa82a88f374c5b41779e88fe40b8
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-09-30 21:20:25 +02:00
Ievgenii Meshcheriakov
52ad59f9ea QThread: Reset the system thread ID when thread exits on Unix
Unix QThread implementation stores pthread_t as a system thread ID
when the thread is created, but never resets the system ID when
those threads are destroyed. Some implementations may reuse the
same thread IDs for new threads, and this may cause QThread::wait()
to erroneously complain that "Thread tried to wait on itself".

This patch sets the system thread ID to nullptr when the thread is
about to exit and be destroyed by the system.

A regression test is added to tst_qthread.

Fixes: QTBUG-96846
Pick-to: 5.15 6.2
Change-Id: I0850425dd0e09af50e59c9038e7e662a2a624beb
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-09-29 01:53:49 +02:00
Thiago Macieira
57960ab075 Q{Elf,Mach}Parser: simplify the return codes
The multi-state return code was a legacy of how Arvid wrote the ELF
parser code back in the day, the fact that it scanned for two different
types of plugins in Qt 4 and that the metadata could exist in different
places.  None of that matters nowadays: who cares if the file is a
corrupt binary, not a valid binary, does not have the right
architecture, or has no suitable section? It's not a plugin, period.

The Qt 4 plugin mechanism was removed for Qt 5.0 in commit
7443895857 ("Remove support for Qt 4 style
plugins").

Change-Id: I42eb903a916645db9900fffd16a442d800399b98
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-09-24 20:16:05 -07:00
Thiago Macieira
60b0b0dedd tst_qplugin{,loader}: make it pass on Macs
Debug builds were broken.

WARNING: tst_QPluginLoader::errorString() testdata bin/libtst_qpluginloaderlib.dylib could not be located!

$ ls -l bin
total 112
-rwxr-xr-x 1 tjmaciei staff 77296 Sep 14 08:46 libtheplugin_debug.dylib
-rwxr-xr-x 1 tjmaciei staff 33408 Sep 14 08:46 libtst_qpluginloaderlib_debug.dylib

Pick-to: 6.2
Change-Id: I42eb903a916645db9900fffd16a4bb0a51ef967c
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-24 11:40:44 -07:00
Alex Trotsenko
d3a622f817 Revert "QProcess: do not emit aboutToClose() twice"
This reverts commit efb90f6e7e.

Reason for revert: behavior change for signal listeners

Change-Id: Ibe3c5d496cd61a9fccab17a10cc9fda8334fc9d4
Reviewed-by: Björn Schäpers <qt-codereview@hazardy.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-09-24 05:57:47 +00:00
Ievgenii Meshcheriakov
fe46cd59ce Add isValidUtf8() methods to QUtf8StringView and QByteArray{,View}
The new methods return true if the string contains valid UTF-8
encoded data, or false otherwise.

[ChangeLog][QtCore][QByteArray] Added isValidUtf8() method.

[ChangeLog][QtCore][QByteArrayView] Added isValidUtf8() method.

[ChangeLog][QtCore][QUtf8StringView] Added isValidUtf8() method.

Task-number: QTBUG-92021
Change-Id: I5d0cb613265d98b1f189c5f5cc09c1f7db302272
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-22 15:40:30 +02:00
Fabian Kosmale
01d94760d8 tst_qmetatype: Fix operator< detection for std::optional
Amends ca54b741d6.
operator< is not constrained in MSVC's standard library, either.

Pick-to: 6.2
Fixes: QTBUG-96690
Change-Id: Ibcbb9e53a1f9e8b13786f6d8c01489c61d8d2d7f
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-09-21 19:27:50 +02:00
Tatiana Borisova
766904bf5b Compile autotests for Integrity
- process environment/DNS are OFF for INTEGRITY

Task-number: QTBUG-96176
Pick-to: 6.2
Change-Id: I189a97f88c96a428586c31a66b8d250e04482900
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-20 17:29:04 +03:00
Edward Welbourne
7943480f0f Fix QDateTimeParser's handling of 't' format to match serialization
This amends commit 68f19fb630 to only
consume one 't' from the format string, to match qlocale.cpp's
serialization of time-zone specifiers, which only consumes one, so
will repeat the time-zone specifier as many times as unquoted t
appears in the format. It's hard to imagine why anyone would want this
behavior, but it's what our serialization has always done and parsing
should match serialization.

Add test-cases for double time-zone specifier.
Delete a lie in the process.

Task-number: QTBUG-95966
Change-Id: I574896040a74085dee89a4fefd8384be44ad827b
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-09-20 15:05:36 +02:00
Alex Trotsenko
efb90f6e7e QProcess: do not emit aboutToClose() twice
This signal is emitted by the QIODevice itself, so we don't have to
emit it from QProcess::close().

Pick-to: 6.1 6.2
Change-Id: I9165b3eebadc17a66cc834d5ef54441d13f23d7d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-09-19 10:42:50 +03:00
Edward Welbourne
7a4b586f4b Remove conditioning on Android embedded
It is no longer handled separately from Android.
This effectively reverts commit 6d50f746fe

Change-Id: Ic2d75b8c5a09895810913311ab2fe3355d4d2983
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-09-17 17:30:14 +02:00
Edward Welbourne
cbd33cb557 Add missing dependencies of tests on their helper programs
This ensures that a command such as

  $ ninja tst_qlocale && ninja tst_qlocale_check

will automagically build the syslocaleapp program that the test runs
from a subtest. Similar for testlib's selftests and tst_QProcess.

As a drive-by, pruned some legacy comments from when CMakeLists.txt
files were generated from .pro files.

Change-Id: I67691a8175aaef124d4104cf1898193993408bdf
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-09-17 12:57:25 +02:00
Ievgenii Meshcheriakov
1afd562b0b QThreadPool: Fix restarting of expired threads
Ensure that expired threads have actually finished before attempting
to restart them. Calling start() on a thread that is not yet finished
does nothing.

Add a regression test into tst_qthreadpool that attempts to trigger
reuse of expired threads and verifies that all submitted tasks
execute.

Fixes: QTBUG-72872
Pick-to: 6.2
Change-Id: I2109b628b8a4e91491115dc56aebf3eb249646b5
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-15 15:46:53 +02:00
Ivan Solovev
61343b5a3f Teach QLocale::system() to use narrow format
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>
2021-09-15 10:29:55 +02:00
Edward Welbourne
8e8a55e660 Tidy up #includes in tst_qlocale.cpp
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>
2021-09-14 13:07:34 +02:00
Edward Welbourne
458d53f572 Move locale-switching code in tests to a shared header
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>
2021-09-14 13:07:13 +02:00
Thiago Macieira
a7fa677fc2 QPlugin/QFactoryLoader: remove Qt 5 plugin remnants
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>
2021-09-14 01:12:18 -07:00
Thiago Macieira
96d21faa01 Re-enable tst_qplugin on Linux
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>
2021-09-14 03:59:45 +00:00
JiDe Zhang
413098c3e3 feat: add new interfaces for std::filesystem::path
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>
2021-09-14 03:18:04 +02:00
Sona Kurazyan
ba8d1da4a9 Skip tst_QReadWriteLock::multipleReadersLoop on QEMU
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>
2021-09-09 21:08:42 +02:00
Ievgenii Meshcheriakov
2c0bdd38cb tst_qstringapisymmetry: Don't pretend that QByteArray contains UTF-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>
2021-09-09 15:02:02 +02:00
Edward Welbourne
4641ff0f6a Add new am/pm format-specifier that preserves locale's case
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>
2021-09-08 20:28:40 +02:00
Thiago Macieira
7e8c7b3ed8 Q_DECLARE_INTERFACE: delete unspecialized qobject_interface_iid()
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>
2021-09-07 12:09:49 -07:00
Sona Kurazyan
9f13842fe6 Fix compilation for recursive Qt containers
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>
2021-09-07 15:48:35 +02:00
Thiago Macieira
115d99b7de tst_QtJson: add matching escape-generating test
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>
2021-09-06 16:23:02 -07:00
Thiago Macieira
b631440902 JSON parsing: fix incorrect sign-extension for decoding bad escapes
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>
2021-09-06 16:23:01 -07:00
Ivan Solovev
78dee15da4 Fix QLocale::system() standalone day and month handling
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>
2021-09-06 20:40:12 +02:00
Ivan Solovev
e300fc9204 Make tst_QLocale::TransientLocale succeed at changing system locale
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>
2021-09-03 14:00:53 +02:00
Thiago Macieira
f3743073a7 qstrnlen: micro-optimize further
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>
2021-09-01 11:32:03 -07:00
Edward Welbourne
38ec2c830b qlocale_win: Fix non-standalone month names
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>
2021-09-01 17:56:46 +02:00
Ievgenii Meshcheriakov
4e460aa3f7 tests: Add test for UTS #46 implementation using Unicode data
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>
2021-09-01 14:15:45 +02:00
Ievgenii Meshcheriakov
c8612b156d tst_qstringapisymmetry: Re-enable trim_trimmed_QByteArray
The testcase was disabled with no explanation in
2766322de3 but seems to work fine.

Change-Id: Ibc22a4ffb756604e22c1f2cf1165919c1d7f1212
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-31 19:45:52 +02:00
Edward Welbourne
4e9efb0b60 Teach QByteArrayView how to parse numbers
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>
2021-08-30 17:46:00 +02:00
Edward Welbourne
5644af6f8a Replace FreeBSD's strtou?ll() with std::from_chars()-based strntou?ll()
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>
2021-08-30 17:46:00 +02:00
Giuseppe D'Angelo
7d4d47de70 QObject::connect(): fail to connect to a functor if UniqueConnection is passed
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>
2021-08-27 15:45:25 +02:00
Giuseppe D'Angelo
f0c2c987e3 QBA(V)/QS(V)::lastIndexOf: fix the search of 1-char needles
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 6cee204d56.

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>
2021-08-26 07:08:34 +02:00
Ievgenii Meshcheriakov
8b5de677a7 tst_qurl{,internal}: Use U+FB01 for normalization to ASCII test cases
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>
2021-08-25 00:13:39 +02:00
Ievgenii Meshcheriakov
d9881799c1 tst_qurlinternal: Remove testcases that use U+04CF
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>
2021-08-25 00:13:39 +02:00
Ievgenii Meshcheriakov
655e353557 tst_qurlinternal: Remove nameprep and STD3 rules tests
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>
2021-08-25 00:13:39 +02:00
Ievgenii Meshcheriakov
5b01399781 tst_qurl: Make an invalid URL test compatible with UTS #46
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>
2021-08-25 00:13:39 +02:00
Giuseppe D'Angelo
bac329a28b QRegularExpressionMatch: add a way to know if a capturing group captured
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>
2021-08-25 00:06:42 +02:00
Joerg Bornemann
d9f8b68963 Revive tst_qresourceengine
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>
2021-08-24 23:27:30 +02:00
Giuseppe D'Angelo
d48058f197 Unicode: fix the grapheme clustering algorithm
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 a794c5e287.

Fixes: QTBUG-94951
Pick-to: 6.1 5.15
Change-Id: If987d5ccf7c6b13de36d049b1b3d88a3c4b6dd00
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-24 12:58:20 +02:00
Edward Welbourne
3878a17137 Use constexpr for constants and ranged-based for loops
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>
2021-08-23 15:11:49 +02:00