diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2021-07-05 09:37:40 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2021-07-05 20:49:36 +0200 |
commit | 09d0fc068d4b32aa9cd00d38171e62fddf82c83a (patch) | |
tree | 3ea16a3f45125a02e264064676d30defcde1aaca /tests/auto/corelib/tools/qcryptographichash | |
parent | f5b76be1e49b1b6acaeaf1c6ec84da6ca7881957 (diff) |
tst_QCryptographicHash: make hashLength() data-driven
Pick-to: 6.1 6.2
Change-Id: I44bf73e15b53b8d93d116f4114bc667c4c94b7b4
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'tests/auto/corelib/tools/qcryptographichash')
-rw-r--r-- | tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp b/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp index ca4a6f7354..c819f02d70 100644 --- a/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp +++ b/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp @@ -49,6 +49,7 @@ private slots: void blake2(); void files_data(); void files(); + void hashLength_data(); void hashLength(); }; @@ -400,15 +401,23 @@ void tst_QCryptographicHash::files() } } -void tst_QCryptographicHash::hashLength() +void tst_QCryptographicHash::hashLength_data() { + QTest::addColumn<QCryptographicHash::Algorithm>("algorithm"); auto metaEnum = QMetaEnum::fromType<QCryptographicHash::Algorithm>(); for (int i = 0, value = metaEnum.value(i); value != -1; value = metaEnum.value(++i)) { auto algorithm = QCryptographicHash::Algorithm(value); - QByteArray output = QCryptographicHash::hash(QByteArrayLiteral("test"), algorithm); - QCOMPARE(QCryptographicHash::hashLength(algorithm), output.length()); + QTest::addRow("%s", metaEnum.valueToKey(value)) << algorithm; } } +void tst_QCryptographicHash::hashLength() +{ + QFETCH(const QCryptographicHash::Algorithm, algorithm); + + QByteArray output = QCryptographicHash::hash(QByteArrayLiteral("test"), algorithm); + QCOMPARE(QCryptographicHash::hashLength(algorithm), output.length()); +} + QTEST_MAIN(tst_QCryptographicHash) #include "tst_qcryptographichash.moc" |