summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qbytearray
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-09-05 06:39:30 +0200
committerLiang Qi <liang.qi@qt.io>2016-09-05 13:57:12 +0200
commit657c2bfbeceda3faa2c7a76b4ccec6a65a3445a2 (patch)
tree83e0a1dab04afb291e181bb8fb6152ba96678795 /tests/auto/corelib/tools/qbytearray
parent676129d7ee57347798683d444823e7723776d8ec (diff)
parentb94111116f09a6e48741d35cf7abea47af99ef26 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: tests/auto/testlib/selftests/generate_expected_output.py Change-Id: If856162abf9a24ae2c9946d336a7d1da03520fa7
Diffstat (limited to 'tests/auto/corelib/tools/qbytearray')
-rw-r--r--tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
index a460afcfa2..a100de4c41 100644
--- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
@@ -790,9 +790,17 @@ void tst_QByteArray::qstrncpy()
{
QByteArray src(1024, 'a'), dst(1024, 'b');
- // singularities
- QCOMPARE(::qstrncpy(0, 0,0), (char*)0);
- QCOMPARE(::qstrncpy(dst.data(), 0, 0), (char*)0);
+ // dst == nullptr
+ QCOMPARE(::qstrncpy(0, src.data(), 0), (char*)0);
+ QCOMPARE(::qstrncpy(0, src.data(), 10), (char*)0);
+
+ // src == nullptr
+ QCOMPARE(::qstrncpy(dst.data(), 0, 0), (char*)0);
+ QCOMPARE(::qstrncpy(dst.data(), 0, 10), (char*)0);
+
+ // valid pointers, but len == 0
+ QCOMPARE(::qstrncpy(dst.data(), src.data(), 0), dst.data());
+ QCOMPARE(*dst.data(), 'b'); // must not have written to dst
// normal copy
QCOMPARE(::qstrncpy(dst.data(), src.data(), src.size()), dst.data());