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/stream/hex_ut.cpp |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'util/stream/hex_ut.cpp')
-rw-r--r-- | util/stream/hex_ut.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/util/stream/hex_ut.cpp b/util/stream/hex_ut.cpp new file mode 100644 index 00000000000..5074a0b6168 --- /dev/null +++ b/util/stream/hex_ut.cpp @@ -0,0 +1,29 @@ +#include "hex.h" + +#include <library/cpp/testing/unittest/registar.h> +#include "str.h" + +Y_UNIT_TEST_SUITE(THexCodingTest) { + void TestImpl(const TString& data) { + TString encoded; + TStringOutput encodedOut(encoded); + HexEncode(data.data(), data.size(), encodedOut); + + UNIT_ASSERT_EQUAL(encoded.size(), data.size() * 2); + + TString decoded; + TStringOutput decodedOut(decoded); + HexDecode(encoded.data(), encoded.size(), decodedOut); + + UNIT_ASSERT_EQUAL(decoded, data); + } + + Y_UNIT_TEST(TestEncodeDecodeToStream) { + TString data = "100ABAcaba500,$%0987123456 \n\t\x01\x02\x03."; + TestImpl(data); + } + + Y_UNIT_TEST(TestEmpty) { + TestImpl(""); + } +} |