diff options
author | xiphon <xiphon@protonmail.com> | 2018-11-15 23:32:42 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-11-15 23:34:15 +0000 |
commit | b36353e2681825474a9ddc6a6ccfe6098995a9f5 (patch) | |
tree | 00c02c658354f0afe9eaaf67c94ca30a5ad7a70c /tests | |
parent | unit_tests: add a test for parse_hexstr_to_binbuff (diff) | |
download | monero-b36353e2681825474a9ddc6a6ccfe6098995a9f5.tar.xz |
unit_tests: add some hex parsing test for non hex input
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit_tests/epee_utils.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/unit_tests/epee_utils.cpp b/tests/unit_tests/epee_utils.cpp index b3c812dca..c384ce9a5 100644 --- a/tests/unit_tests/epee_utils.cpp +++ b/tests/unit_tests/epee_utils.cpp @@ -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) { EXPECT_EQ( |