qt5base-lts/tests/auto/corelib
Marc Mutz d176808eef QByteArray, QString, QStringRef: Add chopped()
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>
2017-04-18 09:43:18 +00:00
..
animation Blacklist a QSequentialAnimationGroup autotest 2017-03-30 12:10:31 +00:00
codecs QTextCodec: add QStringView overloads 2017-04-06 12:05:33 +00:00
global tests: Unify license to GPL-EXCEPT 2017-04-03 07:18:46 +00:00
io QDate/Time: add toString(QStringView) overloads 2017-04-12 11:12:09 +00:00
itemmodels Merge remote-tracking branch 'origin/5.9' into dev 2017-03-28 09:28:31 +02:00
json Merge remote-tracking branch 'origin/5.8' into 5.9 2017-03-27 10:42:08 +02:00
kernel Add QMetaObject::invokeMethod() overloads for function pointers 2017-04-02 08:00:27 +00:00
mimetypes Build examples and tests only if their requirements are met 2017-03-22 15:55:55 +00:00
plugin Merge remote-tracking branch 'origin/5.8' into 5.9 2017-03-13 15:55:44 +01:00
statemachine Merge "Merge remote-tracking branch 'origin/5.6' into dev" into refs/staging/dev 2016-01-26 11:27:37 +00:00
thread Merge remote-tracking branch 'origin/5.9' into dev 2017-03-28 09:28:31 +02:00
tools QByteArray, QString, QStringRef: Add chopped() 2017-04-18 09:43:18 +00:00
xml Build examples and tests only if their requirements are met 2017-03-22 15:55:55 +00:00
corelib.pro Add support for Apple tvOS 2016-05-17 16:11:23 +00:00