diff options
author | Devtools Arcadia <[email protected]> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <[email protected]> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /util/string/hex_ut.cpp |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'util/string/hex_ut.cpp')
-rw-r--r-- | util/string/hex_ut.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/util/string/hex_ut.cpp b/util/string/hex_ut.cpp new file mode 100644 index 00000000000..39a83d5e62b --- /dev/null +++ b/util/string/hex_ut.cpp @@ -0,0 +1,19 @@ +#include "hex.h" + +#include <library/cpp/testing/unittest/registar.h> + +Y_UNIT_TEST_SUITE(THexCodingTest) { + Y_UNIT_TEST(TestEncode) { + UNIT_ASSERT_EQUAL(HexEncode("i1634iqwbf,&msdb"), "693136333469717762662C266D736462"); + } + + Y_UNIT_TEST(TestDecode) { + UNIT_ASSERT_EQUAL(HexDecode("693136333469717762662C266D736462"), "i1634iqwbf,&msdb"); + } + + Y_UNIT_TEST(TestDecodeCase) { + UNIT_ASSERT_EQUAL(HexDecode("12ABCDEF"), HexDecode("12abcdef")); + UNIT_ASSERT_EXCEPTION(HexDecode("Hello"), yexception); //< incorrect chars + UNIT_ASSERT_EXCEPTION(HexDecode("123"), yexception); //< odd length + } +} |