feat(sha256): test

This commit is contained in:
2024-09-11 17:21:37 +03:00
parent 8217e95e85
commit 907fb6d90f
2 changed files with 25 additions and 0 deletions

View File

@ -16,6 +16,7 @@ TOOLS =\
TESTS =\
test-hex\
hash/test-sha256\
ifeq (${origin CC}, default)
CC = g++

24
test/hash/test-sha256.cpp Normal file
View File

@ -0,0 +1,24 @@
#include <base/hash/sha256.hpp>
#include <base/hex.hpp>
#include <gtest/gtest.h>
using namespace hash;
TEST(hash, sha256)
{
EXPECT_EQ(hex::encode(sha256(hex::decode("1234"))), "3a103a4e5729ad68c02a678ae39accfbc0ae208096437401b7ceab63cca0622f");
}
TEST(hash, sha256_1e4)
{
std::vector<uint8_t> data(32);
for(uint64_t i = 0; i < 1e4; i++)
{
sha256(data);
}
}
int main(int argc, char **argv)
{
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}