unit_tests: add some hex parsing test for non hex input

This commit is contained in:
xiphon 2018-11-15 23:32:42 +00:00 committed by moneromooo-monero
parent 6671110ca3
commit b36353e268
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
1 changed files with 16 additions and 0 deletions

View File

@ -469,6 +469,22 @@ TEST(StringTools, ParseHex)
} }
} }
TEST(StringTools, ParseNotHex)
{
std::string res;
for (size_t i = 0; i < 256; ++i)
{
std::string inputHexString = std::string(2, static_cast<char>(i));
if ((i >= '0' && i <= '9') || (i >= 'A' && i <= 'F') || (i >= 'a' && i <= 'f')) {
ASSERT_TRUE(epee::string_tools::parse_hexstr_to_binbuff(inputHexString, res));
} else {
ASSERT_FALSE(epee::string_tools::parse_hexstr_to_binbuff(inputHexString, res));
}
}
ASSERT_FALSE(epee::string_tools::parse_hexstr_to_binbuff(std::string("a"), res));
}
TEST(StringTools, GetIpString) TEST(StringTools, GetIpString)
{ {
EXPECT_EQ( EXPECT_EQ(