blob: f4e8ba5bb091f77bf0a049a48f1e1babf5223123 (
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
}
}
|