summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-09-06 06:56:27 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2016-09-06 06:56:27 +0000
commit23ef3b04ebfc0c7a87800b4ff09444c854e31fdb (patch)
tree5a3509a5de492bf13e8f9dfb96b0cbaaa72dc6d0 /tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
parentbeaa792e2021aad52ecd98a0e0f0f48571069dba (diff)
parentd892e6f721b0163dfb2f2ecf79d80ba62304a542 (diff)
Merge "Merge remote-tracking branch 'origin/5.7' into 5.8" into refs/staging/5.8
Diffstat (limited to 'tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp')
-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 88c505601a..310c5f6fd3 100644
--- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
@@ -778,9 +778,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());