feat(base58): unfixed bug with double \0 and incorrect real str_size

This commit is contained in:
2024-09-19 01:50:32 +03:00
parent f2119850ee
commit 817f6c4fb1
8 changed files with 172 additions and 61 deletions

View File

@ -18,14 +18,14 @@ TEST(base64, isValid)
for (auto it : tests)
EXPECT_EQ(it.first, isValid(it.second));
}
std::vector<std::pair<std::string, std::string>> tests = {
{"", ""},
{"BKUEpQ==", "04a504a5"},
{"BKUEpQA=", "04a504a500"},
{"BKUEpQAA", "04a504a50000"},
};
TEST(base64, encode)
{
std::vector<std::pair<std::string, std::string>> tests = {
{"", ""},
{"BKUEpQ==", "04a504a5"},
{"BKUEpQA=", "04a504a500"},
{"BKUEpQAA", "04a504a50000"},
};
for (auto it : tests)
EXPECT_EQ(it.first, encode(hex::decode(it.second)));
}
@ -36,12 +36,6 @@ TEST(base64, encode_1e7)
}
TEST(base64, decode)
{
std::vector<std::pair<std::string, std::string>> tests = {
{"", ""},
{"BKUEpQ==", "04a504a5"},
{"BKUEpQA=", "04a504a500"},
{"BKUEpQAA", "04a504a50000"},
};
for (auto it : tests)
EXPECT_EQ(hex::encode(decode(it.first)), it.second);
}