summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/text/qstring
Commit message (Collapse)AuthorAgeFilesLines
* QString: add char8_t overload of fromUtf8()Marc Mutz2020-06-232-1/+8
| | | | | | | | | | | | | Use the overload-with-template trick from P1423 to avoid ambiguities when existing callers pass 0 or nullptr. Add a qdoc-ignored macro to hide the fact that the overload is a template. [ChangeLog][QtCore][QString] Added char8_t overload of fromUtf8(). Change-Id: Iaa2d365bfa161ef36cc73fa3bad50aabf34d01db Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove most overloads taking a QStringRef from the QString APILars Knoll2020-06-111-8/+0
| | | | | | | | | | 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>
* Add QStringView::split() methodsLars Knoll2020-06-011-13/+37
| | | | | | | | | | | | | 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>
* Adjust resize() behavior of QString and QByteArray to match Qt 5Lars Knoll2020-05-211-1/+3
| | | | | | | | | | | | | 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>
* QString: fix an aliasing issue in remove(QString)Marc Mutz2020-05-151-0/+10
| | | | | | | | | | | 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>
* Enforce that statically allocated array-like containers have 0 capacityGiuseppe D'Angelo2020-05-141-0/+4
| | | | | | | | | | | | | | | | 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>
* Remove QRegExp support from QString and StringListLars Knoll2020-05-141-120/+2
| | | | | | | | | | 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>
* Get rid of some QTextCodec leftoversLars Knoll2020-05-141-2/+0
| | | | | | | There's no real dependency to QTextCodec in those files anymore. Change-Id: Ifaf19ab554fd108fa26095db4e2bd4a3e9ea427f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QString: remove op+=(char) and op+=(QChar::SpecialCharacter)Marc Mutz2020-05-131-2/+12
| | | | | | | | | | | | | | | | | | | 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>
* Sweep of int-ish → char-ish types near calls to QString::fromU*()Marc Mutz2020-05-121-19/+19
| | | | | | | | | | | | 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>
* Remove useless codeLars Knoll2020-05-011-8/+0
| | | | | | | | | 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>
* Port qtbase/tests/auto/corelib/text tests to CMakeSona Kurazyan2020-04-271-0/+29
| | | | | | Task-number: QTBUG-78220 Change-Id: I497da6ed489854bdee5a1ead9a3f34118c78d001 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* QString: add append, op+=, prepend, insert taking QStringViewMarc Mutz2020-04-241-0/+25
| | | | | | | | | [ChangeLog][QtCore][QString] Now supports appending, prepending and inserting QStringViews. Change-Id: I7538c050c67590f27d91443eda0b94a4b80b62f2 Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove QString::from/toAscii()Lars Knoll2020-04-161-29/+0
| | | | | | | These methods have been deprecated since 5.0 Change-Id: I3ceed57a364ea59a63ccc51452ab3b4da7140ce4 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Make QLocale(QString) explicitLars Knoll2020-04-011-2/+2
| | | | | | | | We should not implicitly convert a QString to a QLocale object. It can easily create unwanted side effects. Change-Id: I7bd9b4a4e4512c0e60176ee4d241d172f00fdc32 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devLars Knoll2020-03-041-0/+3
|\ | | | | | | Change-Id: I99ee6f8b4bdc372437ee60d1feab931487fe55c4
| * Suppress warnings where QString and its tests use SplitBehaviorEdward Welbourne2020-03-031-0/+3
| | | | | | | | | | | | | | | | This is a follow-up to commit 895939c7f91d0c8424a0638c42d05cb42293a142 to fix deprecation warnings it added. Change-Id: I3d86655ec2c84c1bdcac9c70436075fc78f2f781 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-02-261-0/+6
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/network/bearermonitor/CMakeLists.txt examples/network/CMakeLists.txt src/corelib/tools/qlinkedlist.h src/sql/kernel/qsqldriver_p.h src/sql/kernel/qsqlresult_p.h src/widgets/kernel/qwidget.cpp src/widgets/kernel/qwidget_p.h tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp tests/auto/tools/moc/allmocs_baseline_in.json Change-Id: I21a3c34570ae79ea9d30107fae71759d7eac17d9
| * Merge remote-tracking branch 'origin/5.14' into 5.15Liang Qi2020-02-181-0/+6
| |\ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/tools/qlinkedlist.h src/plugins/platforms/wasm/qwasmintegration.cpp src/plugins/platforms/wasm/qwasmscreen.cpp Change-Id: Iefca7f9f4966bdc20e7052aca736874861055738
| | * Only read the first BOM as a BOM; the rest are ZWNBS !Edward Welbourne2020-02-141-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QUtf32::convertToUnicode() was forgetting to set headerdone when it dealt with the header (for contrast, Utf16::convertToUnicode() does). Fixes: QTBUG-62011 Change-Id: Ia254782ce0967a6cf9ce0e81eb06d41521150eed Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Move old tst_QLocale::negativeZero() to tst_QString::number()Edward Welbourne2020-01-301-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | It was more complex than it needed to be and was a test of QString, not of QLocale. This leaves tst_QLocale::negativeZero() available to now test how QLocale handles negative zero. Change-Id: Ic9aae250c29f579e6d60fba8404b38673a3b489f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-01-151-40/+79
|\| | | | | | | | | | | | | | | | | | | | | | | Conflicts: tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp tests/auto/network/access/spdy/tst_spdy.cpp Change-Id: I3196c5f7b34f2ffc9ef1e690d02d5b9bb3270a74
| * | Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2020-01-131-40/+79
| |\| | | | | | | | | | Change-Id: I50f70a789ab1438b40d4408be72c090fa00b801f
| | * QString::isLower/isUpper: redo the implementationGiuseppe D'Angelo2020-01-111-40/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use QStringIterator rather than indexed loops. This fixes handling of non-BMP code points (which may be lower or uppercase, see the test). Change also the semantics of the functions, adopting Unicode §3.13 definitions: a string is lowercase/uppercase if it's equal to its own toLower/toUpper folding. As a side effect, empty strings are now correctly reported to be lowercase AND uppercase. [ChangeLog][Important Behavior Changes] The semantics of QString::isLower() and QString::isUpper() have been changed to match the Unicode specification. Now lowercase (resp. uppercase) strings are allowed to contain any character; a string is considered lowercase (resp. uppercase) if it's equal to its own toLower() (resp. toUpper()) folding. Previously, a non-letter character would make the string not lowercase nor uppercase, and the mere presence of an uppercase (resp. lowercase) letter would make isLower() (resp. isUpper()) return false, even if the letter wouldn't change under case folding. As a consequence, now empty strings are lowercase and uppercase. [ChangeLog][QtCore][QString] Fixed a number of bugs of QString::isLower() and QString::isUpper(). Empty strings are now correctly reported to be lowercase (resp. uppercase), and strings containing code points outside the BMP are now correctly handled. Note that the behavior of these functions has also been changed. Change-Id: Iba1398279a072399a9f21295fe75f6e414f3f813 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | Merge remote-tracking branch 'origin/5.15' into devLiang Qi2020-01-041-0/+48
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/tools/qvector.h Make QVector(DataPointer dd) public to be able to properly merge 5b4b437b30b320e2cd7c9a566999a39772e5d431 from 5.15 into dev. src/widgets/kernel/qapplication.cpp tests/auto/tools/moc/allmocs_baseline_in.json Done-With: Christian Ehrlicher <ch.ehrlicher@gmx.de> Change-Id: I929ba7c036d570382d0454c2c75f6f0d96ddbc01
| * | Introduce QString(View)::isValidUtf16Giuseppe D'Angelo2019-12-201-0/+48
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QString(View)s can be built or manipulated in ways that make them contain/refer to improperly encoded UTF-16 data. Problem is, we don't have public APIs to check whether a string contains valid UTF-16. This knowledge is precious if the string is to be fed in algorithms, regular expressions, etc. that expect validated input (e.g. QRegularExpression can be faster if it can assume valid UTF-16, otherwise it has to employ extra checks). Add a function that does the validation. [ChangeLog][QtCore][QStringView] Added QStringView::isValidUtf16. [ChangeLog][QtCore][QString] Added QString::isValidUtf16. Change-Id: Idd699183f6ec08013046c76c6a5a7c524b6c6fbc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Convert QString to use QArrayDataPointerLars Knoll2019-12-161-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | We're now using the same infrastructure for QVector, QString and QByteArray. This should also make it easier to remove the shared null in a follow-up change. Change-Id: I3aae9cf7912845cfca8e8150e9e82aa3673e3756 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Vitaly Fanaskov <vitaly.fanaskov@qt.io>
* | Use QString::DataPointer instead of QStringPrivateLars Knoll2019-12-081-1/+1
| | | | | | | | | | | | | | | | Preparations to move QString over to use QArrayDataPointer instead of it's own private struct. Change-Id: I7796a595393394083f6a85863e3c710ebbdea149 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Get rid of QCharRef and QByteRefLars Knoll2019-12-081-23/+1
| | | | | | | | | | | | | | | | | | | | We already detach immediately since change c2d2757bccc68e1b981df059786c2e76f2969530. That basically removes the main purpose of having QChar/ByteRef, and we can just as well get rid of those classes for Qt 6. Change-Id: I8dc566a1948ddc29c0cb8a77ec7310654a7219a4 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Inline the size and data pointer members in QStringThiago Macieira2019-12-081-9/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I'd have preferred to use QArrayDataPointer<ushort> for QString, but that option wasn't the best one. QArrayDataPointer try to do some operations using QArrayDataOps and that would expand to unnecessary code. What's more, the existing code expected to be able to modify and access the d pointer. Instead, this commit introduces QStringPrivate (named differently from QStringData to catch potential users), which contains the three members. This POD class is also used in QJsonValue to store the "inlined" QString. QHashedString in qtdeclarative will need a similar solution. Change-Id: I33f072158e6e2cd031d4d2ffc81f4a8dbaf4e616 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Add reference-count manipulation functions to QArrayData and hide refThiago Macieira2019-12-081-3/+3
|/ | | | | | | | The next change will stop using some values in the reference counter as settings from the data. Change-Id: I94df1fe643896373fac2f000fff55bc7708fc807 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Don't try to define QT_NO_CAST_TO_ASCII when the test undefines itEdward Welbourne2019-10-251-1/+1
| | | | | | | | | | | The qmake config for tst_QString tried to impose QT_NO_CAST_TO_ASCII on it, but the source file explicitly #undef-s this symbol and its friends. Leave the define commented out in the .pro so that a comment can explain why it's no good. Change-Id: I7620f4e104f0cdab05fdc246b903c40026e63d76 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Move a test for feature ICU from .pro to .cppEdward Welbourne2019-10-252-11/+11
| | | | | | | | | | | | | Test QT_CONFIG(icu) in the code instead of testing qtConfig(icu) in the profile and setting an extra define just to shadow what's already defined. Also remove the matching define from qcollator.pro, whose test code didn't use it. Noticed while reviewing the conversions to CMake. Change-Id: I19d3b1026b2a8f50ec424c450614e721500fd38a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* Suppress deprecation warnings on a test of a deprecated QString methodEdward Welbourne2019-10-091-0/+3
| | | | | | | | QString::fromAscii() is deprecated since 5.0 but still tested. So suppress deprecations for its code. Change-Id: Ic048a843c43551021da39a16d94c3222201573dc Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Port from QStringViewLiteral to u""Marc Mutz2019-07-291-3/+3
| | | | | | | | | Now that all our supported compilers know char16_t, we no longer need QStringViewLiteral, whose only purpose in life was to turn u"" into L"" for MSVC < 2015. Change-Id: I25a094fe7992d9d5dbeb4a524d9e99e043dcb8ce Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Move text-related code out of corelib/tools/ to corelib/text/Edward Welbourne2019-07-105-0/+17135
This includes byte array, string, char, unicode, locale, collation and regular expressions. Change-Id: I8b125fa52c8c513eb57a0f1298b91910e5a0d786 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>