blob: f4c29a2c902aa2f32ed8afadd4863be5d192c215 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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("");
}
}
|