blob: 485583ce35388494f91d8da29dd75f92a8dda602 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
}
}
|