summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/text/qbytearrayapisymmetry/tst_qbytearrayapisymmetry.cpp
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2021-07-22 16:49:41 +0200
committerIvan Solovev <ivan.solovev@qt.io>2021-07-29 15:00:35 +0200
commit08a1bcfa9b6672d0b71f5b3de0d6c58a8f549ea1 (patch)
tree2d7d84370e6a0e188a1056f55c22befcc4be88b3 /tests/auto/corelib/text/qbytearrayapisymmetry/tst_qbytearrayapisymmetry.cpp
parente150bcfe4d5514b2a2960234049c514bc558adee (diff)
QByteArray: extend unit tests
This patch introduces some test improvements to check the calls of different methods on an empty default-constructed string. Apart from that, many other tests are added to extend code coverage. Task-number: QTBUG-91736 Pick-to: 6.2 6.1 Change-Id: If86ef3d8611a678798b1bcc60a1a4f5598fd2179 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'tests/auto/corelib/text/qbytearrayapisymmetry/tst_qbytearrayapisymmetry.cpp')
-rw-r--r--tests/auto/corelib/text/qbytearrayapisymmetry/tst_qbytearrayapisymmetry.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/auto/corelib/text/qbytearrayapisymmetry/tst_qbytearrayapisymmetry.cpp b/tests/auto/corelib/text/qbytearrayapisymmetry/tst_qbytearrayapisymmetry.cpp
index 40d7291e41..fe0c3efbee 100644
--- a/tests/auto/corelib/text/qbytearrayapisymmetry/tst_qbytearrayapisymmetry.cpp
+++ b/tests/auto/corelib/text/qbytearrayapisymmetry/tst_qbytearrayapisymmetry.cpp
@@ -212,6 +212,8 @@ void tst_QByteArrayApiSymmetry::startsWith_impl()
QVERIFY(haystack.startsWith((char *)0) == result);
} else {
QVERIFY(haystack.startsWith(needle.data()) == result);
+ if (needle.size() == 1)
+ QVERIFY(haystack.startsWith(needle.at(0)) == result);
}
}
@@ -267,6 +269,8 @@ void tst_QByteArrayApiSymmetry::endsWith_impl()
QVERIFY(haystack.endsWith((char *)0) == result);
} else {
QVERIFY(haystack.endsWith(needle.data()) == result);
+ if (needle.size() == 1)
+ QVERIFY(haystack.endsWith(needle.at(0)) == result);
}
}
@@ -509,6 +513,14 @@ void tst_QByteArrayApiSymmetry::count_data()
QTest::addRow("aaa") << QByteArray("aaa") << QByteArray("a") << 3;
QTest::addRow("xyzaaaxyz") << QByteArray("xyzaaxyaxyz") << QByteArray("xyz") << 2;
+ QTest::addRow("a in null") << QByteArray() << QByteArray("a") << 0;
+ QTest::addRow("a in empty") << QByteArray("") << QByteArray("a") << 0;
+ QTest::addRow("xyz in null") << QByteArray() << QByteArray("xyz") << 0;
+ QTest::addRow("xyz in empty") << QByteArray("") << QByteArray("xyz") << 0;
+ QTest::addRow("null in null") << QByteArray() << QByteArray() << 1;
+ QTest::addRow("empty in empty") << QByteArray("") << QByteArray("") << 1;
+ QTest::addRow("empty in null") << QByteArray() << QByteArray("") << 1;
+ QTest::addRow("null in empty") << QByteArray("") << QByteArray() << 1;
const int len = 500;
QByteArray longData(len, 'a');