hex_ut.cpp 681 B

12345678910111213141516171819
  1. #include "hex.h"
  2. #include <library/cpp/testing/unittest/registar.h>
  3. Y_UNIT_TEST_SUITE(THexCodingTest) {
  4. Y_UNIT_TEST(TestEncode) {
  5. UNIT_ASSERT_EQUAL(HexEncode("i1634iqwbf,&msdb"), "693136333469717762662C266D736462");
  6. }
  7. Y_UNIT_TEST(TestDecode) {
  8. UNIT_ASSERT_EQUAL(HexDecode("693136333469717762662C266D736462"), "i1634iqwbf,&msdb");
  9. }
  10. Y_UNIT_TEST(TestDecodeCase) {
  11. UNIT_ASSERT_EQUAL(HexDecode("12ABCDEF"), HexDecode("12abcdef"));
  12. UNIT_ASSERT_EXCEPTION(HexDecode("Hello"), yexception); //< incorrect chars
  13. UNIT_ASSERT_EXCEPTION(HexDecode("123"), yexception); //< odd length
  14. }
  15. } // Y_UNIT_TEST_SUITE(THexCodingTest)