qt5base-lts/tests/auto/corelib
Edward Welbourne e21bf5e6b3 QString::replace(): protect sought text and replacement
When replacing each copy of one text with a copy of another, we do so
in batches of 1024; if we get more than one batch, we need to keep a
copy of the sought text and replacement if they're part of the string
we're modifying, for use in later batches.

Also do the replacements in full batches of 1024, not 1023 (which left
the last entry in an array unused); marked some related tests as
(un)likely; and move some repeated code out into a pair of little
local functions to save duplcation.

Those new functions can also serve replace_helper(); and it can shed a
const_cast and some conditioning of free() by using them the same way
replace() now does.  (There was also one place it still used the raw
after, rather than the replacement copy; which could have produced
errors if memcpy were to exercise its right to assume no overlap in
arrays.  This error is what prompted me to notice all of the above.)

Added tests.  The last error proved untestable as my memcpy is in fact
as fussy as memmove.  The first two tests added were attempts to get a
failure out of it.  The third did get a failure, but also tripped over
the problem in replace() itself.  Added to an existing test function
and renamed it to generally cover extra tests for replace.

Change-Id: I9ba6928c84ece266dbbe52b91e333ea54ab6d95e
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-07-12 10:22:25 +00:00
..
animation Extend tst_QPauseAnimation::pauseAndPropertyAnimations blacklist 2015-06-20 15:25:58 +00:00
codecs Fix utf8->utf16 BOM/ZWNBSP decoding. 2015-12-21 09:56:49 +00:00
global Fix qSetMessagePattern to have many time/backtrace parts 2016-03-25 11:03:43 +00:00
io QUrl: Test that we do correctly accept valid schemes 2016-07-02 16:36:50 +00:00
itemmodels tst_QItemModel: Use a QTemporaryDir for test data of QDirModel. 2015-11-27 22:50:26 +00:00
json Update testdata 2016-02-17 04:50:50 +00:00
kernel Fix crash when connecting a non-PMF with Qt::UniqueConnection... 2016-05-30 00:19:39 +00:00
mimetypes QMimeDatabase: fix mimeTypeForUrl for mailto URLs 2016-04-23 08:44:45 +00:00
plugin Fix qplugin autotest on Windows 2016-06-08 19:40:29 +00:00
statemachine Merge remote-tracking branch 'origin/5.5' into 5.6 2016-01-19 10:03:01 +01:00
thread tst_QAtomicInteger: fix UBs (signed overflow) 2016-03-24 16:16:15 +00:00
tools QString::replace(): protect sought text and replacement 2016-07-12 10:22:25 +00:00
xml Add support for 8bit encodings not ASCII compatible in QXMLStreamWriter. 2016-06-08 18:50:25 +00:00
corelib.pro iOS: Enable building of basic tests 2014-01-22 12:35:17 +01:00