summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-09-05 18:47:27 +0200
committerLiang Qi <liang.qi@qt.io>2016-09-05 18:47:27 +0200
commitd892e6f721b0163dfb2f2ecf79d80ba62304a542 (patch)
treeccc1de7ece77bca11b20b3335126c337720d5e54 /tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp
parent2997a60e1eaf0efbeb22516ae184fa93f278fec5 (diff)
parent657c2bfbeceda3faa2c7a76b4ccec6a65a3445a2 (diff)
Merge remote-tracking branch 'origin/5.7' into 5.8
Conflicts: mkspecs/features/qt_common.prf src/plugins/platforms/windows/qwindowsdialoghelpers.cpp Change-Id: I03b92b6b89ecc5a8db7c95f04ebb92ed198098a8
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());