summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/text/qstringapisymmetry
Commit message (Collapse)AuthorAgeFilesLines
* Rename new slice() method sliced()Marc Mutz2020-06-111-20/+20
| | | | | | | | | | | | | | 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>
* Ensure left/right/mid behave in a compatible wayLars Knoll2020-06-091-24/+100
| | | | | | | | | | | | | | | | | | | | 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>
* Implement first/last/from and slice() for string-like classesLars Knoll2020-06-081-47/+196
| | | | | | | | | | | | 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>
* QString/View: add tokenize() member functionsMarc Mutz2020-06-061-0/+23
| | | | | | | | | [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>
* Limit QByteArray's 8-bit support to ASCIIEdward Welbourne2020-06-041-10/+13
| | | | | | | | | | | | | | | | | | | | | 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>
* Long live QStringTokenizer!Marc Mutz2020-06-031-1/+171
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add support for count() to QStringViewLars Knoll2020-05-301-0/+51
| | | | | | | Make the API more symmetric with regards to both QString and QStringRef. Change-Id: Ia67c53ba708f6c33874d1a127de8e2857ad9b5b8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add toInt() and friends to QStringViewLars Knoll2020-05-291-0/+113
| | | | | | | | | 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>
* tst_qstringapisymmetry: test split() with char16_t sepsMarc Mutz2020-05-081-1/+5
| | | | | Change-Id: I6744291b88d5334764da78375899313ac771294b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Port qtbase/tests/auto/corelib/text tests to CMakeSona Kurazyan2020-04-271-0/+13
| | | | | | Task-number: QTBUG-78220 Change-Id: I497da6ed489854bdee5a1ead9a3f34118c78d001 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* tst_qstringapisymmetry: start testing char16_t, tooMarc Mutz2020-03-051-20/+99
| | | | | | | | | | | | | No surprises, as char16_t is transparently handled by QChar overloads. Ok, one surprise: we seem to have QChar <> QByteArray relational operators, but they don't work for char16_t. Probably members of QChar, so LHS implicit conversions are disabled. Didn't investigate, because it needs to be fixed at some point anyway, but that point is not now. Change-Id: I74e1c9bdd168e6480e18d7d86c1f13412e718a32 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* tst_qstringapisymmetry: fix indexOf/contains/lastIndexOf testsMarc Mutz2020-03-051-69/+91
| | | | | | | | | ... to not fold QChar tests into QString ones. This is needed for adding char16_t tests. Change-Id: I2507d7d68a39ff96cf033eadde10e383dc976dda Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QLatin1String/QStringView: add (missing) member compare()Marc Mutz2020-03-051-3/+5
| | | | | | | | | | | [ChangeLog][QtCore][QLatin1String] Added compare(). [ChangeLog][QtCore][QStringView] Added compare() overloads taking QLatin1String, QChar. Change-Id: Ie2aa400299cb63495e65ce29b2a32133066de826 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QString/QByteArray: make all symmetry-checked member-compare() combinations ↵Marc Mutz2020-03-051-4/+0
| | | | | | | | | | | | | | | | | | | noexcept In QByteArray, they were just not marked as such. In QString and QStringRef, the implicit conversion from QChar to QString would destroy it. Add a QChar overload, delegating to QStringView. Added docs for the new overloads, copying from the nearest neighbor so as to not look out of place. All string classes use different wording for these functions. A cleanup of this state of affairs is out of the scope of this patch. Change-Id: I0b7b1d037aa229bcaf29b793841a18caf977d66b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Extend tst_qstringapisymmetry for member compare()Marc Mutz2020-02-091-2/+158
| | | | | | | | | | | | | | | | | | | | | There were a few surprises: - QByteArray::compare() are missing noexcept (will add) - ibid., called with non-ascii content and CaseInsensitive fails (this was discussed on the ML, with tentative agreement that it's a feature, not a bug; waiting for QUtf8String(View) for a fix, then). - As was the case when we did this exercise with the relational operators, QString(Ref)/QChar is not noexcept (will fix) These have been QEXPECT_FAIL'ed. Not much of the cartesian product is implemented at all, yet. These have been #ifdef'ed with NOT_YET_IMPLEMENTED to see what's still missing. Change-Id: I7d9b21e292b98f980aacdc6248e88188f7472ba2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Move text-related code out of corelib/tools/ to corelib/text/Edward Welbourne2019-07-103-0/+1792
This includes byte array, string, char, unicode, locale, collation and regular expressions. Change-Id: I8b125fa52c8c513eb57a0f1298b91910e5a0d786 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>