summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qstringapisymmetry
Commit message (Collapse)AuthorAgeFilesLines
* qstringapisymmetry: Fix XML parsing failing on invalid encodingsFriedemann Kleint2018-03-021-4/+18
| | | | | | | | | | | | Evaluating testlib's XML output in COIN would fail with: "XML syntax error on line 7520: invalid UTF-8" for the toLatin1() tests due to some Latin1/UTF8 mixup. Add a helper function to convert the data to plain ASCII. Task-number: QTQAINFRA-1797 Change-Id: I1c64878d4c2a67b8c2689905b5ffe6707b5963c1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Mark the previously public qstringalgorithms.h functions privateThiago Macieira2017-10-291-30/+1
| | | | | | | | | | | | | | | | | | | | | Discussed during Qt Contributor Summit 2017. We concluded that we don't want to make these functions public, as they do not follow Qt coding style API. Specifically, qStartsWith(a, b) is not easily understood which argument is the needle and which argument is the haystack (same problem memcpy() has). Compare that to a.startsWith(b) which can clearly be read in English as a subject-verb-object sentence. This commit removes the unit tests that called compare(). Discussed-on: http://lists.qt-project.org/pipermail/development/2017-October/031060.html Change-Id: Icaa86fc7b54d4b368c0efffd14ee6205eb9043fb Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* QStringView/QLatin1String: add trimmed()Marc Mutz2017-05-161-1/+5
| | | | | | | | | | | | | | | | | | | ... using the same qt_trimmed(), qTrimmed(), Q..::trimmed() split we've been using for all other out-of-line string-view member functions to avoid forcing string-view objects onto the stack for the passing of 'this'. In the test, had to fix nullness not being propagated from a QByteArray to the QLatin1String constructed from it. Probably worth fixing in QLatin1String(QByteArray), too. [ChangeLog][QtCore] Added qTrimmed() free functions. [ChangeLog][QtCore][QLatin1String] Added trimmed() function. Change-Id: I73c18ef87e203f30f7552c10dd5c84223bcfae0e Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Enable c++17 in the QStringApiSymmetry testMarc Mutz2017-05-051-0/+1
| | | | | | | Because it's the correct thing to do. Change-Id: I1d9fb482ffed6f4c36b4bc25d05cabcd07d87a78 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* tst_QStringApiSymmetry: add checks for trimmed()Marc Mutz2017-05-031-0/+68
| | | | | | | | All good (now). Change-Id: I666773856a239826e646398a943e7df30bd81671 Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tst_qstringapisymmetry: also check potential rvalue overloads of transformationsMarc Mutz2017-05-031-14/+59
| | | | | | | | | | | | For transformations, regardless of whether they're currently overloaded on rvalue-this or not, check the results of calls to const lvalues as well as mutable rvalues. Use the new mixed-type QCOMPARE more. Change-Id: Ibaa436cd88b40e5c0823c3bbe5b04a9964e7e987 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QLatin1String: add startsWith()/endsWith()Marc Mutz2017-04-281-1/+23
| | | | | | | | | [ChangeLog][QtCore][QLatin1String] Added startsWith(), endsWith(). Change-Id: I7f75a5a1f0409f4b9d3e41b73f4fb5d137572b09 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QStringView: add startsWith(), endsWith()Marc Mutz2017-04-281-1/+23
| | | | | Change-Id: I72aef9236daedc3013c62d3f1d737159f85572b8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QString/Ref: add startsWith/endsWith(QStringView) overloadsMarc Mutz2017-04-281-1/+9
| | | | | | | | | | [ChangeLog][QtCore][QString/QStringRef] Added startsWith(), endsWith() overloads taking QStringView. Change-Id: Ice6332492d19fd7477d5ac43ecbf6b70175b23ca Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* tst_qstringapisymmetry: merge truncate() test into left() testMarc Mutz2017-04-271-44/+24
| | | | | | | | | | | Less code duplication, since truncate() is the action version of left(). This is done in preparation of adding more actions for the string transformations we have. Change-Id: I55027b5143ad3349d46091ac1cc3d24a9707caee Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* tst_qstringviewapisysmmetry: add a check for startsWith()/endsWith()Marc Mutz2017-04-261-0/+235
| | | | | | | | | | | All good. Can't check QByteArray::startsWith(), as it is lacking the Qt::CaseSensitivity parameter. Change-Id: I7f2379e520617c14514fc66d8fb3413cfb7c9147 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QLatin1String: fix qt_compare_strings(QLatin1String, QLatin1String) for null ↵Marc Mutz2017-04-261-0/+40
| | | | | | | | | | | | | | | | | | | strings qstrcmp sorts null strings before empty ones, while the Qt string classes consider them equal. The qt_compare_strings() overload for QLatin1String was using qstrcmp(), but is supposed to implement the semantics that Qt string classes use, so we need to add an extra check. Was uncovered by tests for QLatin1String::startsWith(), but added a new test for qCompareStrings() now, which is a bit more complicated than desired, due to the lack of QUtf8String. Change-Id: I0493c4491df928a68861a1bc7f0962f1c870a416 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QLatin1String: add chopped(), chop(), and truncate()Marc Mutz2017-04-181-0/+4
| | | | | | | | | | [ChangeLog][QtCore][QLatin1String] Added chopped(), chop(), truncate(). Change-Id: I69b31aae560e94a120d7e8a36e06ea957ccd2003 Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QStringView: add chopped(), chop(), and truncate()Marc Mutz2017-04-181-0/+4
| | | | | | Change-Id: I33925f5b2b3e0904f47f18f3cbab480d7f844734 Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QByteArray, QString, QStringRef: Add chopped()Marc Mutz2017-04-181-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have two functions to get a substring without doing some calculations involving size(): - mid(p): mid(p, size() - p) - right(n) : mid(size() - n, n) (left does not involve size(), so isn't in that set). What was missing was a name for - f(n): mid(0, size() - n) As an action, it's called chop(), so call the transformation version chopped(). I made chopped(n), n < 0 or n > size(), undefined, because QString(Ref) ::left() is broken[1], while the QByteArray implementation is not. This is the only way to get consistent behavior among the three classes. I's also the correct thing to do. [1] instead of returning the empty string for negative indexes, it returns the whole string. [ChangeLog][QtCore][QString/QStringRef/QByteArray] Added chopped(n), a const version of chop(n). Change-Id: I6c2c5b16e0060fa924ced5860f21f2d0f23bd023 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
* Add qConvertTo{Utf8,Latin1,Local8Bit,Ucs4}() and corresponding QStringView ↵Marc Mutz2017-04-071-0/+9
| | | | | | | | | | | | | | | | | methods Like the qt_compare_strings()/qCompareStrings() split, distinguish between the internal and exported functions. Because of the circular dependency between qstring.h and qvector.h, the inline toUcs4() function has to be in qvector.h. At some point, we need to refactor the headers so qvector.h is lower in the dependency chain than qstring.h. It's not the first time this bites. Change-Id: Ief9f3bd92c83cdd1f31c51c700f42e146916eefd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_QStringApiSymmetry: Add tests for truncate() and chop()Marc Mutz2017-04-071-0/+90
| | | | | | | | All good. Change-Id: Id791a04fd5e2c9bc7f54660eaaa95d6db61a5674 Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QStringView: add mid(), left(), right()Marc Mutz2017-03-311-0/+6
| | | | | | | | Change-Id: If1d2cf175d51b3c02881e21937b0a2d33b78aadd Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QStringView: add tests for relational operatorsMarc Mutz2017-03-311-1/+23
| | | | | | | | | | | | | Remove most of the std::equal() tests that were used to determine equality in pre-relational-operator-times again. Amends a1421e47871448718fd54e83f0106a38722bdfe4. Change-Id: Iff64808f5ac60861caee899d594b512b58046636 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Add a string API symmetry test for mid/left/rightMarc Mutz2017-03-011-0/+211
| | | | | | | All good. Change-Id: Iab278c24b4bd462d5e77af0c4f0fefb155d00551 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QString(Ref): make toLatin1()/toLocal8Bit() null handling consistentMarc Mutz2017-02-151-0/+196
| | | | | | | | | | | | | | | | | | | | | Systematic testing in tst_QStringApiSymmetry revealed a bug in QStringRef::toLatin1(): a null input did not result in a null output, but an empty one. This is fixed, for consistency with QString::toLatin1(), and QString(Ref)::toUtf8(), which behaved correctly already. The same bug was found in QString(Ref)::toLocal8Bit(), which is particularly hideous, as it's documented to fall back to toLatin1(), which preserves null inputs. Fixed, too. [ChangeLog][QtCore][QString] toLocal8Bit() now preserves nullness of the input QString (outputs null QByteArray). [ChangeLog][QtCore][QStringRef] toLocal8Bit() and toLatin1() now preserve nullness of the input QStringRef (output null QByteArrays). Change-Id: I7026211922c287e03d07e89edbad2987aa646e51 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Use qtConfig throughout in qtbaseLars Knoll2016-08-191-1/+1
| | | | | | | | | | | Use the new qtConfig macro in all pro/pri files. This required adding some feature entries, and adding {private,public}Feature to every referenced already existing entry. Change-Id: I164214dad1154df6ad84e86d99ed14994ef97cf4 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* QStringRef: add missing relational operators against QByteArrayMarc Mutz2016-06-081-3/+0
| | | | | | | | | | | | | | | | | | | | | QStringRef op QByteArray was ambiguous between bool QStringRef::operator op(const char*) const bool operator op(const QStringRef&, const QString&) QByteArray op QStringRef was ambiguous between bool operator op(const QString&, const QStringRef&) bool operator op(const char*, const QStringRef&) Fix by providing more overloads. [ChangeLog][QtCore] Disambiguated the relational operators comparing QByteArray with QStringRef (and vice versa). Change-Id: I1cfa9ecfdd8b4102e652593faf35f6098289bc34 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QString: fix QChar <> QLatin1String relational operators for non-US-ASCIIMarc Mutz2016-06-081-11/+15
| | | | | | | | | | | | | The implementation used the QString::compare_helper(QChar*, int, char*, int) overload, which, however, interprets the rhs as a UTF-8 sequence, not as Latin-1. Fix by using the (QChar*, int, QLatin1String) overload. Extend the test to cover this case, too. Change-Id: I59b26d63d0caec036b80ef8818c75d0cebe519d2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_qstringapisymmetry: cover QByteArray, const char*, tooMarc Mutz2016-06-081-2/+87
| | | | | | | | | As in 032efc2cb20e163a2daf8aef9eb8df2b757d17dc, which added the API-symmetry test, define the missing relational operators locally in the test harness until they are fixed in the library. Change-Id: Ic2688e6b6b3e028a9c29f1a5eb01058375ef3fe9 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QChar: optimize comparison with QString{,Ref}Marc Mutz2016-04-051-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | Instead of relying on the QString relational operators to implicitly convert the QChar to a QString, add relational operator overloads that compare the QChar without first turning it into a QString, saving one memory allocation per comparison, and allowing to mark the operation as nothrow. Consequently, in tst_QStringBinOps, verify now that all relational operations are noexcept. The added overloads make QChar ==/!= int comparisons ambiguous. De-ambiguate by providing a constrained template that matches int and nothing but int (otherwise, the QChar and the int versions would compete for a QChar::SpecialCharacter argument, and end up creating new ambiguities). This solution may not be perfect, but it can be easily extended should more ambiguities crop up. The existing overload deals with all patterns found in qtbase. Change-Id: I4156d918e9b9134c1da684b8b69e0ee526ad24e3 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* QChar: add missing relational operators against QLatin1String/QStringRefMarc Mutz2016-04-051-22/+0
| | | | | | | | | | | | | | | | | | | | | For QChar <> QStringRef, equality and inequality were already provided (via QChar -> QString implicit conversions, to be fixed in a separate patch). Missing were the less/greater than (or equal) operators. Added. For QChar <> QLatin1String, all relational operators were missing. Added, too. [ChangeLog][QtCore][QChar] Added missing operator{<,>,<=,>=} comparing against QLatin1String and QStringRef. [ChangeLog][QtCore][QChar] Added missing operator{==,!=} comparing against QLatin1String. Change-Id: I9941fe7e7281ea560b3bd5970cb9651ffadc1495 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* QStringRef: add missing relational operators against QLatin1String/QStringMarc Mutz2016-03-161-6/+0
| | | | | | | | | | | | | | | | Equality and inequality were already provided. Missing were the less/greater than (or equal) operators. Added. Moved existing functions around and more similar to the new ones, to make the whole code section a bit more manageable. [ChangeLog][QtCore][QStringRef] Added missing operator{<,>,<=,>=} comparing against QLatin1String and QString. Change-Id: Idb3c4fa9b38421637987226f3cc1b77f5d4a6309 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Add test for API symmetry of QString/Ref, QLatin1String, QCharMarc Mutz2016-03-153-0/+203
At the moment, only checks the relational operators, where it already found some which do not compile. In order to simplify the test, the missing operators are supplied by the test harness until they are fixed in the library. Change-Id: Ief5daefa68f15de5f8e559c9378ed83b715b69ee Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>