This commit is contained in:
2024-09-16 17:36:12 +03:00
parent 46ae1a5872
commit 090e765a58
5 changed files with 11 additions and 6 deletions

3
include/libbase Normal file
View File

@ -0,0 +1,3 @@
#include <base/hex.hpp>
#include <base/baseN.hpp>
#include <base/hash/sha256.hpp>

View File

@ -22,6 +22,7 @@ static const int8_t hexmap[] = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
//
};
namespace hex

View File

@ -11,7 +11,7 @@ TEST(hash, sha256)
TEST(hash, sha256_1e4)
{
std::vector<uint8_t> data(32);
for(uint64_t i = 0; i < 1e4; i++)
for (uint64_t i = 0; i < 1e4; i++)
{
sha256(data);
}

View File

@ -24,6 +24,7 @@ static const int8_t b58map[] = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
//
};
TEST(baseN, isValid)

View File

@ -5,7 +5,7 @@ using namespace hex;
TEST(hex, encode)
{
std::vector<uint8_t> data = { 0x74, 0x65, 0x73, 0x74 };
std::vector<uint8_t> data = {0x74, 0x65, 0x73, 0x74};
EXPECT_EQ("74657374", encode(data));
}
TEST(hex, encode_1e6)
@ -15,7 +15,7 @@ TEST(hex, encode_1e6)
}
TEST(hex, decode)
{
std::vector<uint8_t> data = { 0x61, 0x6e, 0x6f };
std::vector<uint8_t> data = {0x61, 0x6e, 0x6f};
EXPECT_EQ(decode("616e6f"), data);
}
TEST(hex, decode_1e6)