MCPcopy Create free account
hub / github.com/catboost/catboost / Y_UNIT_TEST

Function Y_UNIT_TEST

util/string/escape_ut.cpp:50–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48
49Y_UNIT_TEST_SUITE(TEscapeCTest) {
50 Y_UNIT_TEST(TestStrokaEscapeC) {
51 for (const auto& e : CommonTestData) {
52 TString expected(e.Expected);
53 TString source(e.Source);
54 TString actual(EscapeC(e.Source));
55 TString actual2(UnescapeC(e.Expected));
56
57 UNIT_ASSERT_VALUES_EQUAL(e.Expected, actual);
58 UNIT_ASSERT_VALUES_EQUAL(e.Source, actual2);
59 }
60
61 UNIT_ASSERT_VALUES_EQUAL("http://ya.ru/\\x17\\n\\xAB", EscapeC(TString("http://ya.ru/\x17\n\xab")));
62 UNIT_ASSERT_VALUES_EQUAL("http://ya.ru/\x17\n\xab", UnescapeC(TString("http://ya.ru/\\x17\\n\\xAB")));
63 UNIT_ASSERT_VALUES_EQUAL("h", EscapeC('h'));
64 UNIT_ASSERT_VALUES_EQUAL("h", UnescapeC(TString("h")));
65 UNIT_ASSERT_VALUES_EQUAL("\\xFF", EscapeC('\xFF'));
66 UNIT_ASSERT_VALUES_EQUAL("\xFF", UnescapeC(TString("\\xFF")));
67
68 UNIT_ASSERT_VALUES_EQUAL("\\377f", EscapeC(TString("\xff"
69 "f")));
70 UNIT_ASSERT_VALUES_EQUAL("\xff"
71 "f",
72 UnescapeC(TString("\\377f")));
73 UNIT_ASSERT_VALUES_EQUAL("\\xFFg", EscapeC(TString("\xff"
74 "g")));
75 UNIT_ASSERT_VALUES_EQUAL("\xff"
76 "g",
77 UnescapeC(TString("\\xFFg")));
78 UNIT_ASSERT_VALUES_EQUAL("\xEA\x9A\x96", UnescapeC(TString("\\uA696")));
79 UNIT_ASSERT_VALUES_EQUAL("Странный компроматтест", UnescapeC(TString("\\u0421\\u0442\\u0440\\u0430\\u043d\\u043d\\u044b\\u0439 \\u043a\\u043e\\u043c\\u043f\\u0440\\u043e\\u043c\\u0430\\u0442тест")));
80 }
81
82 Y_UNIT_TEST(TestWtrokaEscapeC) {
83 for (const auto& e : CommonTestData) {

Callers

nothing calls this directly

Calls 7

UnescapeCCharLenFunction · 0.85
EscapeCFunction · 0.70
UnescapeCFunction · 0.70
UTF8ToWideFunction · 0.50
testFunction · 0.50
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected