summaryrefslogtreecommitdiff
path: root/tests/auto/qbytearray
diff options
context:
space:
mode:
authorZeno Albisser <zeno.albisser@nokia.com>2010-02-22 14:14:22 +0100
committerZeno Albisser <zeno.albisser@nokia.com>2010-02-23 09:17:21 +0100
commitd1592b1d4f6f0ea0d180e6848af42b3692e7490a (patch)
treefd20dc2031cc76dd59cf64a20f0390f5d362fc6a /tests/auto/qbytearray
parentfcdecd732d2fd6a863e903239f71c8f050c88dd0 (diff)
downloadqt4-tools-d1592b1d4f6f0ea0d180e6848af42b3692e7490a.tar.gz
Added function overload for QByteArray &QByteArray::replace()
This overloaded function can be used to replace a specific portion of a QByteArray with an arbitary amount of characters from a char[]. Reviewed-by: Markus Goetz
Diffstat (limited to 'tests/auto/qbytearray')
-rw-r--r--tests/auto/qbytearray/tst_qbytearray.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/qbytearray/tst_qbytearray.cpp b/tests/auto/qbytearray/tst_qbytearray.cpp
index 5c72c7a572..07fdbc3e62 100644
--- a/tests/auto/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/qbytearray/tst_qbytearray.cpp
@@ -111,6 +111,7 @@ private slots:
void remove();
void replace_data();
void replace();
+ void replaceWithSpecifiedLength();
void indexOf_data();
void indexOf();
void lastIndexOf_data();
@@ -840,6 +841,18 @@ void tst_QByteArray::replace()
QCOMPARE(str2.replace(pos, len, after.data()), expected);
}
+void tst_QByteArray::replaceWithSpecifiedLength()
+{
+ const char after[] = "zxc\0vbnmqwert";
+ int lenAfter = 6;
+ QByteArray ba("abcdefghjk");
+ ba.replace(0,2,after,lenAfter);
+
+ const char _expected[] = "zxc\0vbcdefghjk";
+ QByteArray expected(_expected,sizeof(_expected)-1);
+ QCOMPARE(ba,expected);
+}
+
void tst_QByteArray::indexOf_data()
{
QTest::addColumn<QByteArray>("haystack");