From 577558daf5a2709722cb7980f194cbbc6a8287a3 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Thu, 9 Jul 2020 18:16:13 +0200 Subject: Fix QByteArray::count implementation for longer data The issue has been introduced when refactoring QByteArray::count implementation (see 631127126cc14e7c01cc611532b3256b58785670). Because the last argument of QByteArrayMatcher::indexIn() method has a defult value, it has been compiling without issues, but was being called with incorrect size parameter. Fixed it to pass the length of the input data correctly. Change-Id: Ic9c2f33733131ec17276aa889f2d7ea40ec79b01 Reviewed-by: Alexandru Croitor --- .../text/qbytearrayapisymmetry/tst_qbytearrayapisymmetry.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/auto/corelib/text') diff --git a/tests/auto/corelib/text/qbytearrayapisymmetry/tst_qbytearrayapisymmetry.cpp b/tests/auto/corelib/text/qbytearrayapisymmetry/tst_qbytearrayapisymmetry.cpp index 33fd25cb50..8b51727417 100644 --- a/tests/auto/corelib/text/qbytearrayapisymmetry/tst_qbytearrayapisymmetry.cpp +++ b/tests/auto/corelib/text/qbytearrayapisymmetry/tst_qbytearrayapisymmetry.cpp @@ -490,6 +490,13 @@ void tst_QByteArrayApiSymmetry::count_data() QTest::addRow("aaa") << QByteArray("aaa") << QByteArray("a") << 3; QTest::addRow("xyzaaaxyz") << QByteArray("xyzaaxyaxyz") << QByteArray("xyz") << 2; + + const int len = 500; + QByteArray longData(len, 'a'); + const QByteArray needle("abcdef"); + longData.insert(0, needle); + longData.insert(len / 2, needle); + QTest::addRow("longInput") << longData << needle << 2; } template -- cgit v1.2.3