summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 00f7afc876..779625fc6f 100644
--- a/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp
+++ b/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp
@@ -37,6 +37,7 @@ private slots:
void moreThan4GiBOfData_data();
void moreThan4GiBOfData();
private:
+ void ensureLargeData();
std::vector<char> large;
};
@@ -440,12 +441,14 @@ void tst_QCryptographicHash::swap()
QCOMPARE(hash1.result(), QCryptographicHash::hash("test", QCryptographicHash::Sha256));
}
-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 &) {
@@ -454,7 +457,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) {