Commit Graph

131 Commits

Author SHA1 Message Date
Karsten Heimrich
18ec53156e Move QTextCodec support out of QtCore
* Assume UTF-8 on all Unix like systems
* Export some functions to be able to compile QTextCodec once
  moved to Qt5Compat.

Task-number: QTBUG-75665
Change-Id: I52ec47a848bc0ba72e9c7689668b1bcc5d736c29
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-20 02:04:38 +02:00
Giuseppe D'Angelo
3e1d03b1ea Port Q_STATIC_ASSERT(_X) to static_assert
There is no reason for keep using our macro now that we have C++17.
The macro itself is left in for the moment being, as well as its
detection logic, because it's needed for C code (not everything
supports C11 yet).  A few more cleanups will arrive in the next few
patches.

Note that this is a mere search/replace; some places were using
double braces to work around the presence of commas in a macro, no
attempt has been done to fix those.

tst_qglobal had just some minor changes to keep testing the macro.

Change-Id: I1c1c397d9f3e63db3338842bf350c9069ea57639
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-19 19:38:23 +02:00
Lars Knoll
5caf7ef3b1 Remove deprecated methods
Those aren't part of Qt 6 anymore.

Change-Id: I9ea7de07d89156e8d0fb6ae9deeb24e0de5fa429
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-06-12 15:50:08 +02:00
Marc Mutz
3f6142f5a1 Rename new slice() method sliced()
The recently-added slice() method has the problem that it's a noun
as well as a verb in the imperative. Like std::vector::empty, which
is both an adjective and a verb in the imperative, this may cause
confusion as to what the function does. Using the passive voice form
of slice(), sliced(), removes the confusion. While it can be read as
an adjective, too, that doesn't change the meaning compared to the
verb form.

Change-Id: If0aa01acb6cf5dd5eafa8226e3ea7f7a0c9da4f1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-11 19:14:03 +00:00
Lars Knoll
8ea11e0cf7 Remove most overloads taking a QStringRef from the QString API
Add QStringView overloads where they were missing. This keeps things
almost 100% source compatible.

Task-number: QTBUG-84319
Change-Id: Ica8ee773b2ce655e9597097786117959e34b236e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-06-11 15:52:25 +02:00
Marc Mutz
c549ff3fd4 Also check QStringView(std::nullptr_t) for constexpr'ness
Pick-to: 5.15
Change-Id: I85967caa014fa93d2cd3f26b63e4a85414f6a803
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-06-11 08:24:13 +02:00
Lars Knoll
ecacb3c62f Port QLocale::quoteString from QStringRef to QStringView
Task-number: QTBUG-84319
Change-Id: I29726ebfda7a5f51a0a6ee29e905b0b904256c8d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-06-11 02:50:16 +02:00
Lars Knoll
d2833a3ce5 Ensure left/right/mid behave in a compatible way
QString and QStringRef did bounds checking for left/right/mid, whereas
QStringView was asserting on out of bounds.

Relax the behavior for QStringView and do bounds checking on pos/n
as well. This removes a source of potentially hidden errors when porting
from QStringRef (or QString) to QStringView.

Unfortunately, one difference remains, where QByteArray::left/right()
behaves differently (and somewhat more sane) than QString and
QStringRef. We're keeping the difference here, as it has been around
for many years.

Mark left/right/mid as obsolete and to be replaced with the new
first/last/slice methods.

Change-Id: I18c203799ba78c928a4610a6038089f27696c22e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-06-09 16:51:16 +02:00
Lars Knoll
38096a3d70 Implement first/last/from and slice() for string-like classes
These methods are scheduled as a replacement for left/right/mid()
in Qt 6 with a consistent, narrow contract that does not allow
out of bounds indices, and therefore does permit faster
implementations.

Change-Id: Iabf22e8d4f3fef3c5e69a17f103e6cddebe420b1
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-06-08 13:17:32 +02:00
Oliver Wolff
45b0f1be68 Remove winrt
Macros and the await helper function from qfunctions_winrt(_p).h are
needed in other Qt modules which use UWP APIs on desktop windows.

Task-number: QTBUG-84434
Change-Id: Ice09c11436ad151c17bdccd2c7defadd08c13925
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-06-06 20:25:49 +02:00
Marc Mutz
ee63557112 QString/View: add tokenize() member functions
[ChangeLog][QtCore][QString, QStringView, QLatin1String] Added tokenize().

Change-Id: I5fbeab0ac1809ff2974e565129b61a6bdfb398bc
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-06 02:07:28 +00:00
Edward Welbourne
5f8c6f1760 Rework testing of qstr*cmp() functions
Previously only qstr*icmp() were tested and the test data was sent via
QString and {en,de}coding. Use a local data-type to package pointers
to actual string literals for passing to these functions that take
them.  Fold the various tests involving null pointers and empty
strings into the general testing, removing from "singularity" tests,
and combine the remainders of those tests into a single test of
singular cases for QByteArray::ompare.  Move all these tests to
alongside the existing tests for QByteArray::compare.  Use nullptr
rather than 0 as the null string.

Change-Id: Ie6d01e839c330c2f960af4bcc95e5633539337d6
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-05 12:13:05 +02:00
Alexandru Croitor
f52a48d963 CMake: Fix tst_qregexp test
It was missing the resource files.

Change-Id: Iaa97922eaedc8ba55ef4e568a6abfcffd19509fa
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-06-04 23:20:49 +02:00
Giuseppe D'Angelo
77a8005dcb QStringBuilder: code tidies in the tests
Including other headers, while defining very questionable macro
names, can and will result in trouble. Stop doing that.

While at it, move from including <QtTest> to include-what-you-use,
and clean up the code a bit.

Change-Id: Idb02ef2b612c0805baecac3ce6edd435609aca4c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-04 15:58:02 +02:00
Edward Welbourne
9dd8e655cd Limit QByteArray's 8-bit support to ASCII
Previously it handled Latin-1, which made it incompatible with UTF-8,
which is now our preferred 8-bit encoding. For Qt6 it is limited to
ASCII. Adjusted tests to match. QLatin1String::compare() turned out
to be relying on qstrnicmp()'s Latin-1 handling.

Removed some spurious Q_UNLIKELY()s and tidied up code a little in the
process.

[ChangeLog][QtCore][Important Behavior Changes] Encoding-dependent
features of QByteArrray are now limited to ASCII, where previously
they worked for the whole of Latin-1. This affects case-insensitive
comparison, notably including qstricmp() and qstrnicmp(), and
case-transforming functions.

Fixes: QTBUG-84323
Change-Id: I2925d9908f8654599195a2860847b17083911b41
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-06-04 10:39:53 +02:00
Marc Mutz
6a3c6f939f Long live QStringTokenizer!
This class is designed as C++20-style generator / lazy sequence, and
the new return value of QString{,View}::tokenize().

It thus is more similar to a hand-coded loop around indexOf() than
QString::split(), which returns a container (the filling of which
allocates memory).

The template arguments of QStringTokenizer intricately depend on the
arguments with which it is constructed, so QStringTokenizer cannot be used
directly without C++17 CTAD. To work around this issue, add a factory
function, qTokenize().

LATER:
- ~Optimize QLatin1String needles (avoid repeated L1->UTF16 conversion)~
  (out of scope for QStringTokenizer, should be solved in the respective
  indexOf())
- Keep per-instantiation state:
  * Boyer-Moore table

[ChangeLog][QtCore][QStringTokenizer] New class.

[ChangeLog][QtCore][qTokenize] New function.

Change-Id: I7a7a02e9175cdd3887778f29f2f91933329be759
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-06-03 19:13:54 +02:00
Lars Knoll
aac39167b7 Add QStringView::split() methods
Since QString::split() is not going away in Qt 6, we should aim
to provide API symmetry here, and ease porting existing code from
QString(Ref) to use QStringView.

This is easier than having to port everything to use tokenize() at
the same time. tokenize() will however lead to better performance
and thus should be preferred.

Change-Id: I1eb43300a90167c6e9389ab56f416f2bf7edf506
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-06-01 20:43:21 +02:00
Giuseppe D'Angelo
529f052add Port QRegularExpression to QStringView, drop QStringRef
The idea is pretty simple -- add QRegularExpression matching over
QStringView. When matching over a QString, keep the string
alive (by taking a copy), and set the view onto that string.
Otherwise, just use the view provided by the user (who is then
responsible for ensuring the data stays valid while matching).

Do just minor refactorings to support this use case in a cleaner
fashion.

In QRegularExpressionMatch drop the QStringRef-returning methods, as
they cannot work any more -- in the general case there won't be a
QString to build a QStringRef from.

[ChangeLog][QtCore][QRegularExpression] All the APIs dealing
with QStringRef have been ported to QStringView, following
QStringRef deprecation in Qt 6.0.

Change-Id: Ic367991d9583cc108c045e4387c9b7288c8f1ffd
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-31 21:46:32 +02:00
Lars Knoll
a1056096fc Add support for count() to QStringView
Make the API more symmetric with regards to both QString and QStringRef.

Change-Id: Ia67c53ba708f6c33874d1a127de8e2857ad9b5b8
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-05-30 23:11:09 +02:00
Lars Knoll
beaef85b8d Add toInt() and friends to QStringView
Make the API more symmetric with regards to both QString and QStringRef.
Having this available helps making QStringView more of a drop-in
replacement for QStringRef. QStringRef is planned to get removed in Qt 6.

Change-Id: Ife036c0b55970078f42e1335442ff9ee5f4a2f0d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-05-29 19:01:58 +02:00
Edward Welbourne
449b347644 Rework QLocale and QDateTime tests that expect CET abbreviation
The name CET is locale-dependent; but QLocale doesn't know about
localization of time zone names. Such abbreviated zone names are, in
any case, potentially ambiguous - various zones around the world have
collisions - so they can't be relied on.

QTimeZone's various backends have differing handlings of how to
abbreviate zone names (MS's provides no abbreviated names at all); and
it appears macOS actually follows the relevant localizations.

So it is hopeless to hard-code the expected zone abbreviations.
Changed the tests to consult QTimeZone for the abbreviation and
compare what it gets with the results of checks which should match
this. This is less stringent, but it is at least robustly correct,
thereby getting rid of assorted kludges and #if-ery.

Pick-to: 5.15
Task-number: QTBUG-70149
Change-Id: I0c565de3fd8b5987c8f5a3f785ebd8f6e941e055
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-05-28 15:15:17 +02:00
Lars Knoll
2f05aa82e7 Adjust resize() behavior of QString and QByteArray to match Qt 5
resize() to a smaller size does not reallocate in Qt 5 if the container
is not shared. Match this here.

As a drive-by also fix resize calls on raw data strings to ensure
they are null terminated after the resize.

Change-Id: Ic4d8830e86ed3f247020d7ece3217cebd344ae96
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-05-21 17:59:31 +02:00
Marc Mutz
b655734965 QString: fix an aliasing issue in remove(QString)
Even in Qt 5, remove() can be passed an alias to *this. In Qt 6, with
the advent of substring sharing, this will become even more
pronounced. Use the same fix as was already used in QString::insert().

Pick-to: 5.15
Change-Id: I1a0d3d99fd7dff6e727661646d2cbfdc94df2682
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-05-15 03:00:45 +00:00
Marc Mutz
3b7f278d38 tst_qstringref: remove some wtf?
As best as I can guess, this used the QString::operator=(char), which
I locally removed. Before that lands in Qt, remove this ... wtf?

Pick-to: 5.15
Change-Id: Ie083fe69500d6b5b633416f89f5dd1d7068c20b2
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-05-14 20:30:35 +00:00
Giuseppe D'Angelo
9e1dc1e8a9 QStringView: add converting constructor from array-like containers
Centralize, rather than keeping adding constructors from any
array-like container.

A more robust implementation, likely following the converting
constructor for std::span ([span.cons]), is out of scope for C++17
and will require C++20's ranges and concepts.

[ChangeLog][QtCore][QStringView] QStringView can now be constructed
from any contiguous container, as long as they hold string-like data.
For instance, it's now possible to create a QStringView object
from a std::vector<char16_t>, a QVarLengthArray<ushort> and so on.

Change-Id: I7043eb194f617e98bd1f8af1237777a93a6c5e75
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2020-05-14 12:19:47 +00:00
Giuseppe D'Angelo
594abde1a2 Enforce that statically allocated array-like containers have 0 capacity
It has been the case for both QStringLiteral and QByteArrayLiteral
since Qt 5.0, and Q_ARRAY_LITERAL since Qt 6.0.

Since it's definitely surprising, add a note in the docs, which
is "somehow" consistent with the interpretation of capacity as
the biggest possible size before we reallocate. Since it's 0,
any manipulation of the size will cause a reallocation.
(Alternatively: the capacity() is for how many elements memory was
requested from the free store. No memory was allocated, so 0...)

Task-number: QTBUG-84069
Change-Id: I5c7d21a22d1bd8b8d9b71143e33d537ca0224acd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 14:19:47 +02:00
Lars Knoll
45ed28a9d3 Remove QRegExp from QVariant
Add an operator QVariant() to QRegExp to keep things at source compatible
as possible.

Add a hack to QVariant::load/save() to recognize the old typeid
for QRegExp and stream them correctly as long as the streaming operators
for QRegExp are registered.

Also move the datastream test for QRegExp to tst_qregexp, and adjust it to
the qvariant changes.

Change-Id: I120b38a7541b43ec07a21b17f7f35c55f071eb75
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-05-14 12:19:47 +00:00
Lars Knoll
b2ee684a13 Remove QRegExp support from QString and StringList
Replacement methods do now exist in QRegExp, or
for QRegularExpression when porting to it.

Remove all autotests associated with the old methods.

Change-Id: I3ff1e0da4b53adb64d5a48a30aecd8b960f5e633
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 14:19:47 +02:00
Lars Knoll
7370b60cfe Move methods using QRegExp in QString(List) over to QRegExp
The prepares for the removal of those methods from QString and
QStringList. The new methods in QRegExp are left as a porting help.

Change-Id: Ieffa33a79caf53b83029e9b070c4eb5cadca1418
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-05-14 14:19:47 +02:00
Lars Knoll
57037145f5 Streamline the code in the conversion to and from utf8
Move pre/and post condition handling out of the main loop
to make that one as fast as possible.

Remove special handling of a corner case when the input length
is zero, where the utf8 decoder did something else than all
other decoders.

Change-Id: I94992767ea15405b38f7953adadaa6ff98b20b6f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 07:51:45 +02:00
Lars Knoll
2b8863a98c Get rid of some QTextCodec leftovers
There's no real dependency to QTextCodec in those files anymore.

Change-Id: Ifaf19ab554fd108fa26095db4e2bd4a3e9ea427f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 07:51:20 +02:00
Lars Knoll
9515d45f88 Remove QTextCodec dependency from test
Change-Id: Ie546065c3179d475df46b284ca7df502c4465b93
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 07:50:49 +02:00
Lars Knoll
124d587bb9 Document the string converter classes
Document QStringConverter, QStringDecoder and QStringEncoder.

In addition, do some touches to the API, renaming one enum value,
add a flags argument to one constructor and make some members private.

Change-Id: I8f99dc3d98fb8860cf6fa46301e34b7eb400511b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 07:50:29 +02:00
Lars Knoll
b8db123341 Add a method to determine the encoding for encoded HTML data
This is a replacement for Qt::codecForHtml().

Change-Id: I31f03518fd9c70507cbd210a8bcf405b6a0106b1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 07:49:05 +02:00
Lars Knoll
13af1312f7 Add QStringConverter::encodingForData()
Add method that tries to determine the encoding of the data
from an initial byte order mark.

Change-Id: I348c51a3d4db9b434af53359b739a7e17acfc760
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 07:48:55 +02:00
Lars Knoll
a639bcda1e Add methods to convert between encoding and name to QStringConverter
Add static methods that allow converting between a name for an
encoding and the Encoding enum.

Change-Id: I12bc503cf757ea31d3ca8d5e1f1216efddcb16d4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 07:48:49 +02:00
Lars Knoll
3ce9162ab5 Construct a string converter by name
Add a constructor, that allows constructing a string converter by
name. This is required in some cases and also makes it possible to
(in the future) extend the API to 3rd party encodings.

Also add a name() accessor.

Change-Id: I606d6ce9405ee967f76197b803615e27c5b001cf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 07:48:42 +02:00
Lars Knoll
940665eff5 Add some incremental tests
Feed the data one by one to the encoder or decoder to
verify that the handling of incremental decoding is
correct.

Change-Id: I565e4f1872e00859026334f7662b6778772e159d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 07:48:13 +02:00
Lars Knoll
cab0d57d1e Clean up the Flag handling in QStringConverter
IgnoreHeader was a rather badly defined enum, in addition the
utf8 and utf16 codecs where handling BOMs somewhat different
for stateless decoding.

Fix this by introducing explicit flags for writing a bom when
encoding and not skipping the initial bom when decoding.

Source compatibility for QTextCodec is done with a couple of
static constexpr variables.

Change-Id: I0b2d94f84c937cec1e0494c16ef448c00382691d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 07:47:33 +02:00
Lars Knoll
f64a6bd638 Start work on a new API to replace QTextCodec
The new QStringEncoder and QStringDecoder classes
(with a common QStringConverter base class) are
there to replace QTextCodec in Qt 6.

It currently uses a trivial wrapper around the utf
encoding functionality.

Added some autotests, mostly copied from the text codec
tests.

Change-Id: Ib6eeee55fba918b9424be244cbda9dfd5096f7eb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 07:46:14 +02:00
Marc Mutz
90f864a4c5 QString: remove op+=(char) and op+=(QChar::SpecialCharacter)
The former messes in bad ways with the overload set (it, fatally,
attracts char16_t, e.g.). The latter was probably added in response to
ambiguities between (char) and (QChar). While it's harmless now,
remove it, since it no longer pulls its weight.

The no-ascii warning is now coming from QChar(char), so the protection
isn't lost.

[ChangeLog][QtCore][QString] The += operators taking char and
QChar::SpecialCharacter have been removed as they cause adding a
char16_t to QString to call the char overload, losing information. The
append() function was not affected.

Change-Id: I57116314bcc71c0d9476159513c0c10048239db3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-13 14:38:48 +02:00
Marc Mutz
23849826b4 Sweep of int-ish → char-ish types near calls to QString::fromU*()
The fromUtf16(ushort*) and fromUcs4(uint*) overloads are going
to be deprecated. Use the newer fromUtf16(char16_t*) and
fromUcs4(char32_t*) overloads.

As a drive-by, use std::end()/std::size() where applicable.

Change-Id: I5a93e38cae4a2e33d49c90d06c5f14f7cb7ce90c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-12 05:43:37 +00:00
Marc Mutz
b62bff2ef3 Use QChar::fromUcs4() more
Change-Id: I02be41de92d84145186de9ac5f5ea3541a941964
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-12 07:43:34 +02:00
Andrei Golubev
b428e98052 Make qtbase compile without QT_CONFIG(timezone)
Fixes: QTBUG-83795
Pick-to: 5.15
Change-Id: I05eaaf57d87a9111d3609ebab81bc707f8af98f0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-05-11 14:42:00 +03:00
Marc Mutz
928d57d8da QChar: add fromUcs{2,4}()
The fromUcs2() named ctor is designed to replace all the non-char
integral-type constructors of QChar which make it very hard to control
the implicit QChar conversions, which have caused a few bugs in Qt
itself. As a classical named contructor, it simply returns QChar.

The fromUcs4() named "ctor", however, needs to expand surrogate pairs,
and thus can't just return QChar. Instead, it returns a small struct
that contains one or two char16_t's, can be iterated over and be
implicitly converted to QStringView.  To avoid bikeshedding the name
(FromUcs4Result, of course :), it's defined inline and thus can't be
named outside the function. This function replaces most uses of
QChar::requiresSurrogates() in QtBase.

[ChangeLog][QtCore][QChar] Added fromUcs2(), fromUcs4().

Change-Id: I803708c14001040f75cb599e33c24a3fb8d2579c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-09 06:26:08 +00:00
Marc Mutz
2a11940b2a tst_stringview: remove dead code
wchar_t hasn't been QStringView's storage_type for a very long time
(at least since 5.10). And in Qt 6, we require char16_t support not
only in the compiler, but also in the stdlib, so drop the guards and
the alternative code paths.

Change-Id: I99f28b575f61c16a2497840708beaa4b54a80f57
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-05-08 21:11:17 +02:00
Marc Mutz
dd4e96df52 tst_qstringview: modernize functions in help namespace
They don't work with std::span, since std::span has neither
const_iterator nor cbegin()/cend().

To fix, perfectly forward the return type with decltype(auto) instead
of mentioning T::const_iterator, and rely on the const-qualfication of
the help::c{r,}{begin,end}() functions' arguments to select the
correct T::{r,}{begin,end}() overload.

Change-Id: I4992d4bd521d2dc0f9ea51ae70cde8286ae543a5
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-05-08 16:53:04 +02:00
Marc Mutz
d67551ff5b tst_qstringapisymmetry: test split() with char16_t seps
Change-Id: I6744291b88d5334764da78375899313ac771294b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-05-08 16:52:59 +02:00
Edward Welbourne
48e5a37536 Move a test of QLocale's methods out of tst_QDateTime
It clearly belonged in tst_QDate::toDateTime(), for which it adds a
few more test-case and in which it inspires some further testing.
The new testing of case-insensitivity doesn't work if the format
contains stray non-format characters, so added a new data column to
take care of that.

Pick-to: 5.15
Change-Id: I73619be02091c97024a84cb963c7029e9fd0569a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-08 09:50:24 +02:00
Lars Knoll
52053a8994 Remove useless code
We don't rely on a latin1 locale anymore for the test,
and the other code was not doing anything.

Change-Id: I08bc08d200c9e037884d8b680dfbb24c129f3d2e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2020-05-01 18:52:15 +02:00