summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-03-09 07:46:11 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-03-10 16:18:04 +0000
commiteac394648c29a385156a33168721207d8eab53ff (patch)
treefd4100b592b303666580f83173071ff0d8a85104
parentqsimd_p.h: remove LZCNT feature from the ARCH_HASWELL list (diff)
downloadqtbase-eac394648c29a385156a33168721207d8eab53ff.tar.xz
qtbase-eac394648c29a385156a33168721207d8eab53ff.zip
tst_QCryptographicHash: Extract Method ensureLargeData()
... to make large data usable from other test functions. Change-Id: I302070121a8bb49f373c7711bc3ab9e6418874ef Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> (cherry picked from commit f7ea9b36b7c56bb288f3ea55f587d2ccb8a9b7fa) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp b/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp
index 5e2e854067..2bfe353a91 100644
--- a/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp
+++ b/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp
@@ -35,6 +35,7 @@ private slots:
void moreThan4GiBOfData_data();
void moreThan4GiBOfData();
private:
+ void ensureLargeData();
std::vector<char> large;
};
@@ -401,12 +402,14 @@ void tst_QCryptographicHash::hashLength()
QCOMPARE(QCryptographicHash::hashLength(algorithm), output.length());
}
-void tst_QCryptographicHash::moreThan4GiBOfData_data()
+void tst_QCryptographicHash::ensureLargeData()
{
#if QT_POINTER_SIZE > 4
QElapsedTimer timer;
timer.start();
const size_t GiB = 1024 * 1024 * 1024;
+ if (large.size() == 4 * GiB + 1)
+ return;
try {
large.resize(4 * GiB + 1, '\0');
} catch (const std::bad_alloc &) {
@@ -415,7 +418,14 @@ void tst_QCryptographicHash::moreThan4GiBOfData_data()
QCOMPARE(large.size(), 4 * GiB + 1);
large.back() = '\1';
qDebug("created dataset in %lld ms", timer.elapsed());
+#endif
+}
+void tst_QCryptographicHash::moreThan4GiBOfData_data()
+{
+#if QT_POINTER_SIZE > 4
+ if (ensureLargeData(); large.empty())
+ return;
QTest::addColumn<QCryptographicHash::Algorithm>("algorithm");
auto me = QMetaEnum::fromType<QCryptographicHash::Algorithm>();
auto row = [me] (QCryptographicHash::Algorithm algo) {