tst_QCryptographicHash: Extract Method ensureLargeData()
... to make large data usable from other test functions. Pick-to: 6.5 6.5.0 6.4 6.4.3 6.2 Change-Id: I302070121a8bb49f373c7711bc3ab9e6418874ef Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
6626578036
commit
f7ea9b36b7
@ -37,6 +37,7 @@ private slots:
|
||||
void moreThan4GiBOfData_data();
|
||||
void moreThan4GiBOfData();
|
||||
private:
|
||||
void ensureLargeData();
|
||||
std::vector<char> large;
|
||||
};
|
||||
|
||||
@ -447,12 +448,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 &) {
|
||||
@ -461,7 +464,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) {
|
||||
|
Loading…
Reference in New Issue
Block a user