Skip to content

Commit

Permalink
use constexpr
Browse files Browse the repository at this point in the history
  • Loading branch information
imahjoub committed Sep 8, 2023
1 parent b2dbf3a commit d12d1a7
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions hash_sha256_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ auto hash_sha256_test1() -> bool
constexpr sha256_type hash_result1 = hash1.sha256_result();

static_assert(hash_result1.front() == static_cast<std::uint8_t>(UINT8_C(0xBA)), "Error: Undexpected front-byte Hash Result");
static_assert(hash_result1.back() == static_cast<std::uint8_t>(UINT8_C(0xAD)), "Error: Undexpected back-byte Hash Result");
static_assert(hash_result1.back() == static_cast<std::uint8_t>(UINT8_C(0xAD)), "Error: Undexpected back-byte Hash Result");

constexpr auto result_is_ok = detail::equal(hash_result1.cbegin(), hash_result1.cend(), expected_hash1.cbegin());

Expand All @@ -43,21 +43,21 @@ auto hash_sha256_test1() -> bool
#ifdef HASH_HASH256_PC
auto hash_sha256_test2() -> bool
{
const uint8_t msg2[] =
{
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
};
const uint8_t msg2[] =
{
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
"abcdefghijklmnopqrstuvwxyz"
};

sha256_type expected_hash2 =
{
Expand All @@ -73,6 +73,8 @@ auto hash_sha256_test2() -> bool

hash2.sha256_update(msg2, strlen(reinterpret_cast<const char*>(msg2)));

hash2.sha256_final();

sha256_type hash_result2 = hash2.sha256_result();

return (hash_result2 == expected_hash2);
Expand Down

0 comments on commit d12d1a7

Please sign in to comment.