From 951003d3d5c066c7fffb7658f875d5fbd2ec4857 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 17 May 2024 15:10:51 +0200 Subject: [PATCH] QCryptographicHash: add specific test for static hash() function The test already exercised the function here and there, but it lacked a central place to test the static hash() method, so add one. Pick-to: 6.5 Change-Id: I229bc8a8ed07e0036f60de62ecc4d11ef88dd20e Reviewed-by: Ahmad Samir Reviewed-by: Thiago Macieira (cherry picked from commit 8586f9e1b9fa553b7fe450bbb45ef2cfbd3dd404) Reviewed-by: Qt Cherry-pick Bot --- .../qcryptographichash/tst_qcryptographichash.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp b/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp index 447dca309b1..fe1a9b828af 100644 --- a/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp +++ b/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp @@ -20,6 +20,8 @@ private slots: void repeated_result(); void intermediary_result_data(); void intermediary_result(); + void static_hash_data() { intermediary_result_data(); } + void static_hash(); void sha1(); void sha3_data(); void sha3(); @@ -198,6 +200,17 @@ void tst_QCryptographicHash::intermediary_result() hash.reset(); } +void tst_QCryptographicHash::static_hash() +{ + QFETCH(const int, algo); + QFETCH(const QByteArray, first); + QFETCH(const QByteArray, hash_first); + + const auto _algo = QCryptographicHash::Algorithm(algo); + + QCOMPARE(QCryptographicHash::hash(first, _algo), hash_first); +} + void tst_QCryptographicHash::sha1() {