diff options
author | Vlad Yaroslavlev <vladon@vladon.com> | 2022-02-10 16:46:25 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:25 +0300 |
commit | 344ea37b4a345701ab0e67de2266a1c1bd7baf2d (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /library/cpp/unicode/punycode/punycode_ut.cpp | |
parent | 706b83ed7de5a473436620367af31fc0ceecde07 (diff) | |
download | ydb-344ea37b4a345701ab0e67de2266a1c1bd7baf2d.tar.gz |
Restoring authorship annotation for Vlad Yaroslavlev <vladon@vladon.com>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/unicode/punycode/punycode_ut.cpp')
-rw-r--r-- | library/cpp/unicode/punycode/punycode_ut.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/library/cpp/unicode/punycode/punycode_ut.cpp b/library/cpp/unicode/punycode/punycode_ut.cpp index bb192169d7..97271cf0d8 100644 --- a/library/cpp/unicode/punycode/punycode_ut.cpp +++ b/library/cpp/unicode/punycode/punycode_ut.cpp @@ -11,10 +11,10 @@ namespace { } Y_UNIT_TEST_SUITE(TPunycodeTest) { - static bool TestRaw(const TString& utf8, const TString& punycode) { - TUtf16String unicode = UTF8ToWide(utf8); - TString buf1; - TUtf16String buf2; + static bool TestRaw(const TString& utf8, const TString& punycode) { + TUtf16String unicode = UTF8ToWide(utf8); + TString buf1; + TUtf16String buf2; return HasSameBuffer(WideToPunycode(unicode, buf1), buf1) && buf1 == punycode && HasSameBuffer(PunycodeToWide(punycode, buf2), buf2) && buf2 == unicode && WideToPunycode(unicode) == punycode && PunycodeToWide(punycode) == unicode; } @@ -48,25 +48,25 @@ Y_UNIT_TEST_SUITE(TPunycodeTest) { UNIT_ASSERT_EXCEPTION(PunycodeToWide("-"), TPunycodeError); { - TString longIn; + TString longIn; for (size_t i = 0; i < 1024; ++i) longIn += "Qй"; - TString longOut = "QQQQQQQQQQQQQQQQQQQQQQQQQQ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_ASSERT(TestRaw(longIn, longOut)); } } - static bool TestHostName(const TString& utf8, const TString& punycode, bool canBePunycode = false) { - TUtf16String unicode = UTF8ToWide(utf8); - TString buf1; - TUtf16String buf2; + static bool TestHostName(const TString& utf8, const TString& punycode, bool canBePunycode = false) { + TUtf16String unicode = UTF8ToWide(utf8); + TString buf1; + TUtf16String buf2; //Cerr << "Testing " << utf8 << Endl; return HostNameToPunycode(unicode) == punycode && HostNameToPunycode(UTF8ToWide(punycode)) == punycode // repeated encoding should give same result && PunycodeToHostName(punycode) == unicode && CanBePunycodeHostName(punycode) == canBePunycode; } - static bool TestForced(const TString& bad) { + static bool TestForced(const TString& bad) { return ForceHostNameToPunycode(UTF8ToWide(bad)) == bad && ForcePunycodeToHostName(bad) == UTF8ToWide(bad); } @@ -89,25 +89,25 @@ Y_UNIT_TEST_SUITE(TPunycodeTest) { { // non-ascii - TString bad = "президент.рф"; + TString bad = "президент.рф"; UNIT_ASSERT_EXCEPTION(PunycodeToHostName("президент.рф"), TPunycodeError); UNIT_ASSERT(ForcePunycodeToHostName(bad) == UTF8ToWide(bad)); } { // too long domain label - TString bad(500, 'a'); + TString bad(500, 'a'); UNIT_ASSERT_EXCEPTION(HostNameToPunycode(UTF8ToWide(bad)), TPunycodeError); UNIT_ASSERT(TestForced(bad)); // but can decode it } { // already has ACE prefix - TString bad("xn--яндекс.xn--рф"); + TString bad("xn--яндекс.xn--рф"); UNIT_ASSERT_EXCEPTION(HostNameToPunycode(UTF8ToWide(bad)), TPunycodeError); UNIT_ASSERT(TestForced(bad)); } { // empty non-root domain is not allowed (?) - TString bad(".яндекс.рф"); + TString bad(".яндекс.рф"); UNIT_ASSERT_EXCEPTION(HostNameToPunycode(UTF8ToWide(bad)), TPunycodeError); UNIT_ASSERT(TestForced(bad)); } |