diff options
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 0000000000..5074a0b616 --- /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(""); + } +} |