aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp
diff options
context:
space:
mode:
authorantonovvk <antonovvk@yandex-team.ru>2022-02-10 16:47:52 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:52 +0300
commit37de222addabbef336dcaaea5f7c7645a629fc6d (patch)
treec0748b5dcbade83af788c0abfa89c0383d6b779c /library/cpp
parent37a63debdc21e372d99e1808cdd31aecf75018c3 (diff)
downloadydb-37de222addabbef336dcaaea5f7c7645a629fc6d.tar.gz
Restoring authorship annotation for <antonovvk@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp')
-rw-r--r--library/cpp/binsaver/bin_saver.h6
-rw-r--r--library/cpp/diff/diff.cpp104
-rw-r--r--library/cpp/diff/diff.h188
-rw-r--r--library/cpp/diff/diff_ut.cpp338
-rw-r--r--library/cpp/diff/ut/ya.make26
-rw-r--r--library/cpp/diff/ya.make20
-rw-r--r--library/cpp/string_utils/url/url.cpp24
-rw-r--r--library/cpp/string_utils/url/url.h2
-rw-r--r--library/cpp/string_utils/url/url_ut.cpp18
-rw-r--r--library/cpp/testing/unittest/registar.cpp36
-rw-r--r--library/cpp/testing/unittest/registar.h6
-rw-r--r--library/cpp/uri/common.h10
-rw-r--r--library/cpp/uri/other.cpp84
-rw-r--r--library/cpp/uri/other.h28
-rw-r--r--library/cpp/uri/uri_ut.cpp2
15 files changed, 446 insertions, 446 deletions
diff --git a/library/cpp/binsaver/bin_saver.h b/library/cpp/binsaver/bin_saver.h
index eeec186b06..412424889f 100644
--- a/library/cpp/binsaver/bin_saver.h
+++ b/library/cpp/binsaver/bin_saver.h
@@ -189,16 +189,16 @@ private:
if (IsReading()) {
data.clear();
TStoredSize nSize;
- Add(2, &nSize);
+ Add(2, &nSize);
for (TStoredSize i = 0; i < nSize; ++i) {
- typename T::value_type member;
+ typename T::value_type member;
Add(1, &member);
data.insert(member);
}
} else {
TStoredSize nSize = data.size();
CheckOverflow(nSize, data.size());
- Add(2, &nSize);
+ Add(2, &nSize);
for (const auto& elem : data) {
auto member = elem;
Add(1, &member);
diff --git a/library/cpp/diff/diff.cpp b/library/cpp/diff/diff.cpp
index 90c15bdb61..be57da7f39 100644
--- a/library/cpp/diff/diff.cpp
+++ b/library/cpp/diff/diff.cpp
@@ -1,27 +1,27 @@
-#include "diff.h"
-
-#include <util/generic/hash.h>
-#include <util/digest/fnv.h>
-
+#include "diff.h"
+
+#include <util/generic/hash.h>
+#include <util/digest/fnv.h>
+
#include <iterator>
-template <typename T>
-struct TCollectionImpl {
+template <typename T>
+struct TCollectionImpl {
TVector<TConstArrayRef<T>> Words;
TVector<ui64> Keys;
-
- inline bool Consume(const T* b, const T* e, const T*) {
- if (b < e) {
- Words.push_back(TConstArrayRef<T>(b, e));
- Keys.push_back(FnvHash<ui64>((const char*)b, (e - b) * sizeof(T)));
- }
- return true;
- }
-
+
+ inline bool Consume(const T* b, const T* e, const T*) {
+ if (b < e) {
+ Words.push_back(TConstArrayRef<T>(b, e));
+ Keys.push_back(FnvHash<ui64>((const char*)b, (e - b) * sizeof(T)));
+ }
+ return true;
+ }
+
TConstArrayRef<T> Remap(const TConstArrayRef<ui64>& keys) const {
- if (keys.empty()) {
- return TConstArrayRef<T>();
- }
+ if (keys.empty()) {
+ return TConstArrayRef<T>();
+ }
auto firstWordPos = std::distance(Keys.data(), keys.begin());
auto lastWordPos = std::distance(Keys.data(), keys.end()) - 1;
Y_ASSERT(firstWordPos >= 0);
@@ -29,59 +29,59 @@ struct TCollectionImpl {
Y_ASSERT(static_cast<size_t>(lastWordPos) < Words.size());
return TConstArrayRef<T>(Words[firstWordPos].begin(), Words[lastWordPos].end());
- }
-
- TConstArrayRef<ui64> GetKeys() const {
+ }
+
+ TConstArrayRef<ui64> GetKeys() const {
return TConstArrayRef<ui64>(Keys);
- }
-};
-
-template <typename T>
-struct TCollection {
-};
-
-template <>
-struct TCollection<char>: public TCollectionImpl<char> {
+ }
+};
+
+template <typename T>
+struct TCollection {
+};
+
+template <>
+struct TCollection<char>: public TCollectionImpl<char> {
TCollection(const TStringBuf& str, const TString& delims) {
TSetDelimiter<const char> set(delims.data());
- TKeepDelimiters<TCollection<char>> c(this);
- SplitString(str.begin(), str.end(), set, c);
- }
-};
-
-template <>
+ TKeepDelimiters<TCollection<char>> c(this);
+ SplitString(str.begin(), str.end(), set, c);
+ }
+};
+
+template <>
struct TCollection<wchar16>: public TCollectionImpl<wchar16> {
TCollection(const TWtringBuf& str, const TUtf16String& delims) {
TSetDelimiter<const wchar16> set(delims.data());
TKeepDelimiters<TCollection<wchar16>> c(this);
- SplitString(str.begin(), str.end(), set, c);
- }
-};
-
+ SplitString(str.begin(), str.end(), set, c);
+ }
+};
+
size_t NDiff::InlineDiff(TVector<TChunk<char>>& chunks, const TStringBuf& left, const TStringBuf& right, const TString& delims) {
- if (delims.empty()) {
+ if (delims.empty()) {
return InlineDiff<char>(chunks, TConstArrayRef<char>(left.data(), left.size()), TConstArrayRef<char>(right.data(), right.size()));
- }
- TCollection<char> c1(left, delims);
- TCollection<char> c2(right, delims);
+ }
+ TCollection<char> c1(left, delims);
+ TCollection<char> c2(right, delims);
TVector<TChunk<ui64>> diff;
const size_t dist = InlineDiff<ui64>(diff, c1.GetKeys(), c2.GetKeys());
for (const auto& it : diff) {
chunks.push_back(TChunk<char>(c1.Remap(it.Left), c2.Remap(it.Right), c1.Remap(it.Common)));
- }
+ }
return dist;
-}
-
+}
+
size_t NDiff::InlineDiff(TVector<TChunk<wchar16>>& chunks, const TWtringBuf& left, const TWtringBuf& right, const TUtf16String& delims) {
- if (delims.empty()) {
+ if (delims.empty()) {
return InlineDiff<wchar16>(chunks, TConstArrayRef<wchar16>(left.data(), left.size()), TConstArrayRef<wchar16>(right.data(), right.size()));
- }
+ }
TCollection<wchar16> c1(left, delims);
TCollection<wchar16> c2(right, delims);
TVector<TChunk<ui64>> diff;
const size_t dist = InlineDiff<ui64>(diff, c1.GetKeys(), c2.GetKeys());
for (const auto& it : diff) {
chunks.push_back(TChunk<wchar16>(c1.Remap(it.Left), c2.Remap(it.Right), c1.Remap(it.Common)));
- }
+ }
return dist;
-}
+}
diff --git a/library/cpp/diff/diff.h b/library/cpp/diff/diff.h
index 941c93c796..94fb00cd0b 100644
--- a/library/cpp/diff/diff.h
+++ b/library/cpp/diff/diff.h
@@ -1,112 +1,112 @@
-#pragma once
-
+#pragma once
+
#include <library/cpp/lcs/lcs_via_lis.h>
-
+
#include <util/generic/algorithm.h>
#include <util/generic/array_ref.h>
-#include <util/generic/strbuf.h>
-#include <util/generic/vector.h>
-#include <util/stream/output.h>
-#include <util/string/split.h>
-
-namespace NDiff {
- template <typename T>
- struct TChunk {
- TConstArrayRef<T> Left;
- TConstArrayRef<T> Right;
- TConstArrayRef<T> Common;
-
+#include <util/generic/strbuf.h>
+#include <util/generic/vector.h>
+#include <util/stream/output.h>
+#include <util/string/split.h>
+
+namespace NDiff {
+ template <typename T>
+ struct TChunk {
+ TConstArrayRef<T> Left;
+ TConstArrayRef<T> Right;
+ TConstArrayRef<T> Common;
+
TChunk() = default;
-
- TChunk(const TConstArrayRef<T>& left, const TConstArrayRef<T>& right, const TConstArrayRef<T>& common)
- : Left(left)
- , Right(right)
- , Common(common)
- {
- }
- };
-
- template <typename T>
+
+ TChunk(const TConstArrayRef<T>& left, const TConstArrayRef<T>& right, const TConstArrayRef<T>& common)
+ : Left(left)
+ , Right(right)
+ , Common(common)
+ {
+ }
+ };
+
+ template <typename T>
size_t InlineDiff(TVector<TChunk<T>>& chunks, const TConstArrayRef<T>& left, const TConstArrayRef<T>& right) {
- TConstArrayRef<T> s1(left);
- TConstArrayRef<T> s2(right);
-
- bool swapped = false;
- if (s1.size() < s2.size()) {
- // NLCS will silently swap strings if second string is longer
- // So we swap strings here and remember the fact since it is crucial to diff
- DoSwap(s1, s2);
- swapped = true;
- }
-
+ TConstArrayRef<T> s1(left);
+ TConstArrayRef<T> s2(right);
+
+ bool swapped = false;
+ if (s1.size() < s2.size()) {
+ // NLCS will silently swap strings if second string is longer
+ // So we swap strings here and remember the fact since it is crucial to diff
+ DoSwap(s1, s2);
+ swapped = true;
+ }
+
TVector<T> lcs;
- NLCS::TLCSCtx<T> ctx;
- NLCS::MakeLCS<T>(s1, s2, &lcs, &ctx);
-
- // Start points of current common and diff parts
+ NLCS::TLCSCtx<T> ctx;
+ NLCS::MakeLCS<T>(s1, s2, &lcs, &ctx);
+
+ // Start points of current common and diff parts
const T* c1 = nullptr;
const T* c2 = nullptr;
- const T* d1 = s1.begin();
- const T* d2 = s2.begin();
-
- // End points of current common parts
- const T* e1 = s1.begin();
- const T* e2 = s2.begin();
-
+ const T* d1 = s1.begin();
+ const T* d2 = s2.begin();
+
+ // End points of current common parts
+ const T* e1 = s1.begin();
+ const T* e2 = s2.begin();
+
size_t dist = s1.size() - lcs.size();
- const size_t n = ctx.ResultBuffer.size();
- for (size_t i = 0; i <= n && (e1 != s1.end() || e2 != s2.end());) {
- if (i < n) {
- // Common character exists
- // LCS is marked against positions in s2
- // Save the beginning of common part in s2
- c2 = s2.begin() + ctx.ResultBuffer[i];
- // Find the beginning of common part in s1
+ const size_t n = ctx.ResultBuffer.size();
+ for (size_t i = 0; i <= n && (e1 != s1.end() || e2 != s2.end());) {
+ if (i < n) {
+ // Common character exists
+ // LCS is marked against positions in s2
+ // Save the beginning of common part in s2
+ c2 = s2.begin() + ctx.ResultBuffer[i];
+ // Find the beginning of common part in s1
c1 = Find(e1, s1.end(), *c2);
- // Follow common substring
- for (e1 = c1, e2 = c2; i < n && *e1 == *e2; ++e1, ++e2) {
- ++i;
- }
- } else {
- // No common character, common part is empty
- c1 = s1.end();
- c2 = s2.end();
- e1 = s1.end();
- e2 = s2.end();
- }
-
- TChunk<T> chunk(TConstArrayRef<T>(d1, c1), TConstArrayRef<T>(d2, c2), TConstArrayRef<T>(c1, e1));
- if (swapped) {
- DoSwap(chunk.Left, chunk.Right);
- chunk.Common = TConstArrayRef<T>(c2, e2);
- }
- chunks.push_back(chunk);
-
- d1 = e1;
- d2 = e2;
- }
+ // Follow common substring
+ for (e1 = c1, e2 = c2; i < n && *e1 == *e2; ++e1, ++e2) {
+ ++i;
+ }
+ } else {
+ // No common character, common part is empty
+ c1 = s1.end();
+ c2 = s2.end();
+ e1 = s1.end();
+ e2 = s2.end();
+ }
+
+ TChunk<T> chunk(TConstArrayRef<T>(d1, c1), TConstArrayRef<T>(d2, c2), TConstArrayRef<T>(c1, e1));
+ if (swapped) {
+ DoSwap(chunk.Left, chunk.Right);
+ chunk.Common = TConstArrayRef<T>(c2, e2);
+ }
+ chunks.push_back(chunk);
+
+ d1 = e1;
+ d2 = e2;
+ }
return dist;
- }
-
- template <typename TFormatter, typename T>
+ }
+
+ template <typename TFormatter, typename T>
void PrintChunks(IOutputStream& out, const TFormatter& fmt, const TVector<TChunk<T>>& chunks) {
for (typename TVector<TChunk<T>>::const_iterator chunk = chunks.begin(); chunk != chunks.end(); ++chunk) {
- if (!chunk->Left.empty() || !chunk->Right.empty()) {
- out << fmt.Special("(");
- out << fmt.Left(chunk->Left);
- out << fmt.Special("|");
- out << fmt.Right(chunk->Right);
- out << fmt.Special(")");
- }
- out << fmt.Common(chunk->Common);
- }
- }
-
- // Without delimiters calculates character-wise diff
- // With delimiters calculates token-wise diff
+ if (!chunk->Left.empty() || !chunk->Right.empty()) {
+ out << fmt.Special("(");
+ out << fmt.Left(chunk->Left);
+ out << fmt.Special("|");
+ out << fmt.Right(chunk->Right);
+ out << fmt.Special(")");
+ }
+ out << fmt.Common(chunk->Common);
+ }
+ }
+
+ // Without delimiters calculates character-wise diff
+ // With delimiters calculates token-wise diff
size_t InlineDiff(TVector<TChunk<char>>& chunks, const TStringBuf& left, const TStringBuf& right, const TString& delims = TString());
size_t InlineDiff(TVector<TChunk<wchar16>>& chunks, const TWtringBuf& left, const TWtringBuf& right, const TUtf16String& delims = TUtf16String());
-
+
}
diff --git a/library/cpp/diff/diff_ut.cpp b/library/cpp/diff/diff_ut.cpp
index 99b8167f44..b82a7b000e 100644
--- a/library/cpp/diff/diff_ut.cpp
+++ b/library/cpp/diff/diff_ut.cpp
@@ -1,41 +1,41 @@
-#include "diff.h"
-
+#include "diff.h"
+
#include <library/cpp/testing/unittest/registar.h>
-
-using namespace NDiff;
-
-struct TDiffTester {
- TStringStream Res;
+
+using namespace NDiff;
+
+struct TDiffTester {
+ TStringStream Res;
TVector<TChunk<char>> Chunks;
-
- TStringBuf Special(const TStringBuf& str) const {
- return str;
- }
-
- TStringBuf Common(const TConstArrayRef<const char>& str) const {
- return TStringBuf(str.begin(), str.end());
- }
-
- TStringBuf Left(const TConstArrayRef<const char>& str) const {
- return TStringBuf(str.begin(), str.end());
- }
-
- TStringBuf Right(const TConstArrayRef<const char>& str) const {
- return TStringBuf(str.begin(), str.end());
- }
-
+
+ TStringBuf Special(const TStringBuf& str) const {
+ return str;
+ }
+
+ TStringBuf Common(const TConstArrayRef<const char>& str) const {
+ return TStringBuf(str.begin(), str.end());
+ }
+
+ TStringBuf Left(const TConstArrayRef<const char>& str) const {
+ return TStringBuf(str.begin(), str.end());
+ }
+
+ TStringBuf Right(const TConstArrayRef<const char>& str) const {
+ return TStringBuf(str.begin(), str.end());
+ }
+
void Test(const TStringBuf& a, const TStringBuf& b, const TString& delims = " \t\n") {
- Chunks.clear();
- InlineDiff(Chunks, a, b, delims);
- Res.clear();
- PrintChunks(Res, *this, Chunks);
- }
-
+ Chunks.clear();
+ InlineDiff(Chunks, a, b, delims);
+ Res.clear();
+ PrintChunks(Res, *this, Chunks);
+ }
+
const TString& Result() const {
- return Res.Str();
- }
-};
-
+ return Res.Str();
+ }
+};
+
Y_UNIT_TEST_SUITE(DiffTokens) {
Y_UNIT_TEST(ReturnValue) {
TVector<TChunk<char>> res;
@@ -50,148 +50,148 @@ Y_UNIT_TEST_SUITE(DiffTokens) {
}
Y_UNIT_TEST(EqualStringsOneToken) {
- TDiffTester tester;
-
- tester.Test("aaa", "aaa");
- //~ Cerr << tester.Result() << Endl;
- UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "aaa");
- }
-
+ TDiffTester tester;
+
+ tester.Test("aaa", "aaa");
+ //~ Cerr << tester.Result() << Endl;
+ UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "aaa");
+ }
+
Y_UNIT_TEST(NonCrossingStringsOneToken) {
- TDiffTester tester;
-
- tester.Test("aaa", "bbb");
- //~ Cerr << tester.Result() << Endl;
- UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|bbb)");
-
- tester.Test("aaa", "bbbb");
- //~ Cerr << tester.Result() << Endl;
- UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|bbbb)");
- }
-
+ TDiffTester tester;
+
+ tester.Test("aaa", "bbb");
+ //~ Cerr << tester.Result() << Endl;
+ UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|bbb)");
+
+ tester.Test("aaa", "bbbb");
+ //~ Cerr << tester.Result() << Endl;
+ UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|bbbb)");
+ }
+
Y_UNIT_TEST(Simple) {
- TDiffTester tester;
-
- tester.Test("aaa", "abb", "");
- //~ Cerr << tester.Result() << Endl;
- UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "a(aa|bb)");
-
- tester.Test("aac", "abc", "");
- //~ Cerr << tester.Result() << Endl;
- UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "a(a|b)c");
-
- tester.Test("123", "133", "");
- //~ Cerr << tester.Result() << Endl;
- UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "1(2|3)3");
-
- tester.Test("[1, 2, 3]", "[1, 3, 3]", "");
- //~ Cerr << tester.Result() << Endl;
- UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "[1, (2|3), 3]");
- }
-
+ TDiffTester tester;
+
+ tester.Test("aaa", "abb", "");
+ //~ Cerr << tester.Result() << Endl;
+ UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "a(aa|bb)");
+
+ tester.Test("aac", "abc", "");
+ //~ Cerr << tester.Result() << Endl;
+ UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "a(a|b)c");
+
+ tester.Test("123", "133", "");
+ //~ Cerr << tester.Result() << Endl;
+ UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "1(2|3)3");
+
+ tester.Test("[1, 2, 3]", "[1, 3, 3]", "");
+ //~ Cerr << tester.Result() << Endl;
+ UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "[1, (2|3), 3]");
+ }
+
Y_UNIT_TEST(CommonCharOneToken) {
- TDiffTester tester;
-
- tester.Test("abcde", "accfg");
- //~ Cerr << tester.Result() << Endl;
- UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(abcde|accfg)");
- }
-
+ TDiffTester tester;
+
+ tester.Test("abcde", "accfg");
+ //~ Cerr << tester.Result() << Endl;
+ UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(abcde|accfg)");
+ }
+
Y_UNIT_TEST(EqualStringsTwoTokens) {
- TDiffTester tester;
-
- TStringBuf str("aaa bbb");
- tester.Test(str, str);
-
- //~ Cerr << tester.Result() << Endl;
- UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "aaa bbb");
- }
-
+ TDiffTester tester;
+
+ TStringBuf str("aaa bbb");
+ tester.Test(str, str);
+
+ //~ Cerr << tester.Result() << Endl;
+ UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "aaa bbb");
+ }
+
Y_UNIT_TEST(NonCrossingStringsTwoTokens) {
- TDiffTester tester;
-
- tester.Test("aaa bbb", "ccc ddd");
- //~ Cerr << tester.Result() << Endl;
- UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|ccc) (bbb|ddd)");
-
- tester.Test("aaa bbb", "c d");
- //~ Cerr << tester.Result() << Endl;
- UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|c) (bbb|d)");
- }
-
+ TDiffTester tester;
+
+ tester.Test("aaa bbb", "ccc ddd");
+ //~ Cerr << tester.Result() << Endl;
+ UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|ccc) (bbb|ddd)");
+
+ tester.Test("aaa bbb", "c d");
+ //~ Cerr << tester.Result() << Endl;
+ UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|c) (bbb|d)");
+ }
+
Y_UNIT_TEST(SimpleTwoTokens) {
- TDiffTester tester;
-
- tester.Test("aaa ccd", "abb cce");
- //~ Cerr << tester.Result() << Endl;
- UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|abb) (ccd|cce)");
-
- tester.Test("aac cbb", "aa bb");
- //~ Cerr << tester.Result() << Endl;
- UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aac|aa) (cbb|bb)");
- }
-
+ TDiffTester tester;
+
+ tester.Test("aaa ccd", "abb cce");
+ //~ Cerr << tester.Result() << Endl;
+ UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|abb) (ccd|cce)");
+
+ tester.Test("aac cbb", "aa bb");
+ //~ Cerr << tester.Result() << Endl;
+ UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aac|aa) (cbb|bb)");
+ }
+
Y_UNIT_TEST(MixedTwoTokens) {
- TDiffTester tester;
-
- tester.Test("aaa bbb", "bbb aaa");
- //~ Cerr << tester.Result() << Endl;
- UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(|bbb )aaa( bbb|)");
-
- tester.Test("aaa bbb", " bbb aaa");
- //~ Cerr << tester.Result() << Endl;
- UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|) bbb(| aaa)");
-
- tester.Test(" aaa bbb ", " bbb aaa ");
- //~ Cerr << tester.Result() << Endl;
- UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(| bbb) aaa (bbb |)");
-
- tester.Test("aaa bb", " bbb aa");
- //~ Cerr << tester.Result() << Endl;
- UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|) (bb|bbb aa)");
- }
-
+ TDiffTester tester;
+
+ tester.Test("aaa bbb", "bbb aaa");
+ //~ Cerr << tester.Result() << Endl;
+ UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(|bbb )aaa( bbb|)");
+
+ tester.Test("aaa bbb", " bbb aaa");
+ //~ Cerr << tester.Result() << Endl;
+ UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|) bbb(| aaa)");
+
+ tester.Test(" aaa bbb ", " bbb aaa ");
+ //~ Cerr << tester.Result() << Endl;
+ UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(| bbb) aaa (bbb |)");
+
+ tester.Test("aaa bb", " bbb aa");
+ //~ Cerr << tester.Result() << Endl;
+ UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|) (bb|bbb aa)");
+ }
+
Y_UNIT_TEST(TwoTokensInOneString) {
- TDiffTester tester;
-
- tester.Test("aaa bbb", "aaa");
- //~ Cerr << tester.Result() << Endl;
- UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "aaa( bbb|)");
-
- tester.Test("aaa bbb", "aaa ");
- //~ Cerr << tester.Result() << Endl;
- UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "aaa (bbb|)");
-
- tester.Test("aaa bbb", " bbb");
- //~ Cerr << tester.Result() << Endl;
- UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|) bbb");
-
- tester.Test("aaa bbb", "bbb");
- //~ Cerr << tester.Result() << Endl;
- UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa |)bbb");
- }
-
+ TDiffTester tester;
+
+ tester.Test("aaa bbb", "aaa");
+ //~ Cerr << tester.Result() << Endl;
+ UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "aaa( bbb|)");
+
+ tester.Test("aaa bbb", "aaa ");
+ //~ Cerr << tester.Result() << Endl;
+ UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "aaa (bbb|)");
+
+ tester.Test("aaa bbb", " bbb");
+ //~ Cerr << tester.Result() << Endl;
+ UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa|) bbb");
+
+ tester.Test("aaa bbb", "bbb");
+ //~ Cerr << tester.Result() << Endl;
+ UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "(aaa |)bbb");
+ }
+
Y_UNIT_TEST(Multiline) {
- TDiffTester tester;
-
- tester.Test("aaa\nabc\nbbb", "aaa\nacc\nbbb");
- //~ Cerr << tester.Result() << Endl;
- UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "aaa\n(abc|acc)\nbbb");
-
- tester.Test("aaa\nabc\nbbb", "aaa\nac\nbbb");
- //~ Cerr << tester.Result() << Endl;
- UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "aaa\n(abc|ac)\nbbb");
- }
-
+ TDiffTester tester;
+
+ tester.Test("aaa\nabc\nbbb", "aaa\nacc\nbbb");
+ //~ Cerr << tester.Result() << Endl;
+ UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "aaa\n(abc|acc)\nbbb");
+
+ tester.Test("aaa\nabc\nbbb", "aaa\nac\nbbb");
+ //~ Cerr << tester.Result() << Endl;
+ UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "aaa\n(abc|ac)\nbbb");
+ }
+
Y_UNIT_TEST(DifferentDelimiters) {
- TDiffTester tester;
-
- tester.Test("aaa bbb", "aaa\tbbb");
- //~ Cerr << tester.Result() << Endl;
- UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "aaa( |\t)bbb");
-
- tester.Test(" aaa\tbbb\n", "\taaa\nbbb ");
- //~ Cerr << tester.Result() << Endl;
- UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "( |\t)aaa(\t|\n)bbb(\n| )");
- }
-}
+ TDiffTester tester;
+
+ tester.Test("aaa bbb", "aaa\tbbb");
+ //~ Cerr << tester.Result() << Endl;
+ UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "aaa( |\t)bbb");
+
+ tester.Test(" aaa\tbbb\n", "\taaa\nbbb ");
+ //~ Cerr << tester.Result() << Endl;
+ UNIT_ASSERT_VALUES_EQUAL(tester.Result(), "( |\t)aaa(\t|\n)bbb(\n| )");
+ }
+}
diff --git a/library/cpp/diff/ut/ya.make b/library/cpp/diff/ut/ya.make
index ccdb460885..360134d186 100644
--- a/library/cpp/diff/ut/ya.make
+++ b/library/cpp/diff/ut/ya.make
@@ -1,15 +1,15 @@
-UNITTEST()
-
-OWNER(antonovvk)
-
+UNITTEST()
+
+OWNER(antonovvk)
+
SRCDIR(library/cpp/diff)
-
-PEERDIR(
+
+PEERDIR(
library/cpp/diff
-)
-
-SRCS(
- diff_ut.cpp
-)
-
-END()
+)
+
+SRCS(
+ diff_ut.cpp
+)
+
+END()
diff --git a/library/cpp/diff/ya.make b/library/cpp/diff/ya.make
index 6a40910b3e..a05b7ccbbc 100644
--- a/library/cpp/diff/ya.make
+++ b/library/cpp/diff/ya.make
@@ -1,14 +1,14 @@
-LIBRARY()
-
-OWNER(antonovvk)
-
+LIBRARY()
+
+OWNER(antonovvk)
+
PEERDIR(
library/cpp/lcs
library/cpp/containers/stack_array
-)
-
+)
+
SRCS(
- diff.cpp
-)
-
-END()
+ diff.cpp
+)
+
+END()
diff --git a/library/cpp/string_utils/url/url.cpp b/library/cpp/string_utils/url/url.cpp
index bb75f02491..85f4ac5d69 100644
--- a/library/cpp/string_utils/url/url.cpp
+++ b/library/cpp/string_utils/url/url.cpp
@@ -83,12 +83,12 @@ size_t GetHttpPrefixSize(const wchar16* url, bool ignorehttps) noexcept {
size_t GetHttpPrefixSize(const TStringBuf url, bool ignorehttps) noexcept {
return GetHttpPrefixSizeImpl<char>(url.data(), TKnownSize(url.size()), ignorehttps);
-}
-
+}
+
size_t GetHttpPrefixSize(const TWtringBuf url, bool ignorehttps) noexcept {
return GetHttpPrefixSizeImpl<wchar16>(url.data(), TKnownSize(url.size()), ignorehttps);
-}
-
+}
+
TStringBuf CutHttpPrefix(const TStringBuf url, bool ignorehttps) noexcept {
return CutHttpPrefixImpl(url, ignorehttps);
}
@@ -109,20 +109,20 @@ size_t GetSchemePrefixSize(const TStringBuf url) noexcept {
const char* n = delim.brk(url.data(), url.end());
if (n + 2 >= url.end() || *n != ':' || n[1] != '/' || n[2] != '/') {
- return 0;
+ return 0;
}
- return n + 3 - url.begin();
+ return n + 3 - url.begin();
}
TStringBuf GetSchemePrefix(const TStringBuf url) noexcept {
- return url.Head(GetSchemePrefixSize(url));
-}
-
+ return url.Head(GetSchemePrefixSize(url));
+}
+
TStringBuf CutSchemePrefix(const TStringBuf url) noexcept {
- return url.Tail(GetSchemePrefixSize(url));
-}
-
+ return url.Tail(GetSchemePrefixSize(url));
+}
+
template <bool KeepPort>
static inline TStringBuf GetHostAndPortImpl(const TStringBuf url) {
TStringBuf urlNoScheme = url;
diff --git a/library/cpp/string_utils/url/url.h b/library/cpp/string_utils/url/url.h
index 0d73b409f1..84137ccc57 100644
--- a/library/cpp/string_utils/url/url.h
+++ b/library/cpp/string_utils/url/url.h
@@ -30,7 +30,7 @@ size_t GetHttpPrefixSize(const wchar16* url, bool ignorehttps = false) noexcept;
Y_PURE_FUNCTION
size_t GetHttpPrefixSize(const TStringBuf url, bool ignorehttps = false) noexcept;
-
+
Y_PURE_FUNCTION
size_t GetHttpPrefixSize(const TWtringBuf url, bool ignorehttps = false) noexcept;
diff --git a/library/cpp/string_utils/url/url_ut.cpp b/library/cpp/string_utils/url/url_ut.cpp
index 48aaeb661f..1588013893 100644
--- a/library/cpp/string_utils/url/url_ut.cpp
+++ b/library/cpp/string_utils/url/url_ut.cpp
@@ -77,16 +77,16 @@ Y_UNIT_TEST_SUITE(TUtilUrlTest) {
UNIT_ASSERT_VALUES_EQUAL("file://yandex.ru", AddSchemePrefix("file://yandex.ru"));
UNIT_ASSERT_VALUES_EQUAL("ftp://ya.ru", AddSchemePrefix("ya.ru", "ftp"));
}
-
+
Y_UNIT_TEST(TestSchemeGet) {
- UNIT_ASSERT_VALUES_EQUAL("http://", GetSchemePrefix("http://ya.ru/bebe"));
- UNIT_ASSERT_VALUES_EQUAL("", GetSchemePrefix("yaru"));
- UNIT_ASSERT_VALUES_EQUAL("yaru://", GetSchemePrefix("yaru://ya.ru://zzz"));
- UNIT_ASSERT_VALUES_EQUAL("", GetSchemePrefix("ya.ru://zzz"));
- UNIT_ASSERT_VALUES_EQUAL("ftp://", GetSchemePrefix("ftp://ya.ru://zzz"));
- UNIT_ASSERT_VALUES_EQUAL("https://", GetSchemePrefix("https://")); // is that right?
- }
-
+ UNIT_ASSERT_VALUES_EQUAL("http://", GetSchemePrefix("http://ya.ru/bebe"));
+ UNIT_ASSERT_VALUES_EQUAL("", GetSchemePrefix("yaru"));
+ UNIT_ASSERT_VALUES_EQUAL("yaru://", GetSchemePrefix("yaru://ya.ru://zzz"));
+ UNIT_ASSERT_VALUES_EQUAL("", GetSchemePrefix("ya.ru://zzz"));
+ UNIT_ASSERT_VALUES_EQUAL("ftp://", GetSchemePrefix("ftp://ya.ru://zzz"));
+ UNIT_ASSERT_VALUES_EQUAL("https://", GetSchemePrefix("https://")); // is that right?
+ }
+
Y_UNIT_TEST(TestSchemeCut) {
UNIT_ASSERT_VALUES_EQUAL("ya.ru/bebe", CutSchemePrefix("http://ya.ru/bebe"));
UNIT_ASSERT_VALUES_EQUAL("yaru", CutSchemePrefix("yaru"));
diff --git a/library/cpp/testing/unittest/registar.cpp b/library/cpp/testing/unittest/registar.cpp
index 8dbcb8ab95..3679b768ed 100644
--- a/library/cpp/testing/unittest/registar.cpp
+++ b/library/cpp/testing/unittest/registar.cpp
@@ -2,7 +2,7 @@
#include <library/cpp/diff/diff.h>
#include <library/cpp/colorizer/colors.h>
-
+
#include <util/generic/bt_exception.h>
#include <util/random/fast.h>
#include <util/string/printf.h>
@@ -62,7 +62,7 @@ void ::NUnitTest::NPrivate::SetUnittestThread(bool unittestThread) {
Y_VERIFY(UnittestThread != unittestThread, "state check");
UnittestThread = unittestThread;
}
-
+
void ::NUnitTest::NPrivate::SetCurrentTest(TTestBase* test) {
Y_VERIFY(!test || !currentTest, "state check");
currentTest = test;
@@ -72,10 +72,10 @@ NUnitTest::TTestBase* ::NUnitTest::NPrivate::GetCurrentTest() {
return currentTest;
}
-struct TDiffColorizer {
- NColorizer::TColors Colors;
+struct TDiffColorizer {
+ NColorizer::TColors Colors;
bool Reverse = false;
-
+
explicit TDiffColorizer(bool reverse = false)
: Reverse(reverse)
{
@@ -83,19 +83,19 @@ struct TDiffColorizer {
TString Special(TStringBuf str) const {
return ToString(Colors.YellowColor()) + str;
- }
-
+ }
+
TString Common(TArrayRef<const char> str) const {
return ToString(Colors.OldColor()) + TString(str.begin(), str.end());
- }
-
+ }
+
TString Left(TArrayRef<const char> str) const {
return ToString(GetLeftColor()) + TString(str.begin(), str.end());
- }
-
+ }
+
TString Right(TArrayRef<const char> str) const {
return ToString(GetRightColor()) + TString(str.begin(), str.end());
- }
+ }
TStringBuf GetLeftColor() const {
return Reverse ? Colors.RedColor() : Colors.GreenColor();
@@ -104,8 +104,8 @@ struct TDiffColorizer {
TStringBuf GetRightColor() const {
return Reverse ? Colors.GreenColor() : Colors.RedColor();
}
-};
-
+};
+
struct TTraceDiffFormatter {
bool Reverse = false;
@@ -144,17 +144,17 @@ TString NUnitTest::GetResetTag() {
}
TString NUnitTest::ColoredDiff(TStringBuf s1, TStringBuf s2, const TString& delims, bool reverse) {
- TStringStream res;
+ TStringStream res;
TVector<NDiff::TChunk<char>> chunks;
- NDiff::InlineDiff(chunks, s1, s2, delims);
+ NDiff::InlineDiff(chunks, s1, s2, delims);
if (NUnitTest::ShouldColorizeDiff) {
NDiff::PrintChunks(res, TDiffColorizer(reverse), chunks);
} else {
res << NUnitTest::GetResetTag();
NDiff::PrintChunks(res, TTraceDiffFormatter(reverse), chunks);
}
- return res.Str();
-}
+ return res.Str();
+}
static TString MakeTestName(const NUnitTest::ITestSuiteProcessor::TTest& test) {
return TStringBuilder() << test.unit->name << "::" << test.name;
diff --git a/library/cpp/testing/unittest/registar.h b/library/cpp/testing/unittest/registar.h
index 22c0eaafa4..44517a0092 100644
--- a/library/cpp/testing/unittest/registar.h
+++ b/library/cpp/testing/unittest/registar.h
@@ -44,7 +44,7 @@ namespace NUnitTest {
TString ColoredDiff(TStringBuf s1, TStringBuf s2, const TString& delims = TString(), bool reverse = false);
TString GetFormatTag(const char* name);
TString GetResetTag();
-
+
// Raise error handler
// Used for testing library/cpp/testing/unittest macroses
// and unittest helpers.
@@ -456,8 +456,8 @@ public: \
if (_a != _b) { \
UNIT_FAIL_IMPL("strings (" #A ") and (" #B ") are different", Sprintf("\n%s", ::NUnitTest::ColoredDiff(_a, _b, " \t\n.,:;'\"").data())); \
} \
- } while (false)
-
+ } while (false)
+
//strings
#define UNIT_ASSERT_STRINGS_UNEQUAL_C(A, B, C) \
do { \
diff --git a/library/cpp/uri/common.h b/library/cpp/uri/common.h
index feb9bf6148..8025357763 100644
--- a/library/cpp/uri/common.h
+++ b/library/cpp/uri/common.h
@@ -492,15 +492,15 @@ namespace NUri {
Y_DECLARE_OUT_SPEC(inline, NUri::TField::EField, out, t) {
out << NUri::FieldToString(t);
-}
-
+}
+
Y_DECLARE_OUT_SPEC(inline, NUri::TScheme::EKind, out, t) {
out << NUri::SchemeKindToString(t);
-}
-
+}
+
Y_DECLARE_OUT_SPEC(inline, NUri::TState::EParsed, out, t) {
out << NUri::ParsedStateToString(t);
-}
+}
static inline ui16 DefaultPort(NUri::TScheme::EKind scheme) {
return NUri::TSchemeInfo::GetDefaultPort(scheme);
diff --git a/library/cpp/uri/other.cpp b/library/cpp/uri/other.cpp
index 5f1ff30b25..b23a5b68a9 100644
--- a/library/cpp/uri/other.cpp
+++ b/library/cpp/uri/other.cpp
@@ -6,34 +6,34 @@
/********************************************************/
/********************************************************/
-static const Tr InvertTr(".:/?#", "\005\004\003\002\001");
-static const Tr RevertTr("\005\004\003\002\001", ".:/?#");
-
+static const Tr InvertTr(".:/?#", "\005\004\003\002\001");
+static const Tr RevertTr("\005\004\003\002\001", ".:/?#");
+
void TrspChars(char* s) {
- InvertTr.Do(s);
-}
-
+ InvertTr.Do(s);
+}
+
void UnTrspChars(char* s) {
- RevertTr.Do(s);
-}
-
+ RevertTr.Do(s);
+}
+
void TrspChars(char* s, size_t l) {
- InvertTr.Do(s, l);
-}
-
+ InvertTr.Do(s, l);
+}
+
void UnTrspChars(char* s, size_t l) {
- RevertTr.Do(s, l);
-}
-
+ RevertTr.Do(s, l);
+}
+
void TrspChars(const char* s, char* d) {
- InvertTr.Do(s, d);
-}
-
+ InvertTr.Do(s, d);
+}
+
void UnTrspChars(const char* s, char* d) {
- RevertTr.Do(s, d);
-}
-
-void InvertDomain(char* begin, char* end) {
+ RevertTr.Do(s, d);
+}
+
+void InvertDomain(char* begin, char* end) {
// skip schema if it is present
const auto dotPos = TStringBuf{begin, end}.find('.');
if (dotPos == TStringBuf::npos)
@@ -41,27 +41,27 @@ void InvertDomain(char* begin, char* end) {
const auto schemaendPos = TStringBuf{begin, end}.find("://", 3);
if (schemaendPos < dotPos)
begin += schemaendPos + 3;
- char* sl = (char*)memchr(begin, '/', end - begin);
- char* cl = (char*)memchr(begin, ':', sl ? sl - begin : end - begin);
- end = cl ? cl : (sl ? sl : end);
-
- // invert string
- for (size_t i = 0, n = end - begin; i < n / 2; ++i)
- DoSwap(begin[i], begin[n - i - 1]);
-
- // invert back each host name segment
- char* b = begin;
- while (true) {
- char* e = (char*)memchr(b, '.', end - b);
- if (!e)
- e = end;
- for (size_t i = 0, n = e - b; i < n / 2; ++i)
- DoSwap(b[i], b[n - i - 1]);
+ char* sl = (char*)memchr(begin, '/', end - begin);
+ char* cl = (char*)memchr(begin, ':', sl ? sl - begin : end - begin);
+ end = cl ? cl : (sl ? sl : end);
+
+ // invert string
+ for (size_t i = 0, n = end - begin; i < n / 2; ++i)
+ DoSwap(begin[i], begin[n - i - 1]);
+
+ // invert back each host name segment
+ char* b = begin;
+ while (true) {
+ char* e = (char*)memchr(b, '.', end - b);
+ if (!e)
+ e = end;
+ for (size_t i = 0, n = e - b; i < n / 2; ++i)
+ DoSwap(b[i], b[n - i - 1]);
if (e == end)
- break;
- b = e + 1;
- }
-}
+ break;
+ b = e + 1;
+ }
+}
void InvertUrl(char* begin, char* end) {
char* slash = strchr(begin, '/');
diff --git a/library/cpp/uri/other.h b/library/cpp/uri/other.h
index e4fd48842a..7aec22e77b 100644
--- a/library/cpp/uri/other.h
+++ b/library/cpp/uri/other.h
@@ -2,23 +2,23 @@
#include <util/generic/string.h>
-// Some functions for inverted url representation
-// No scheme cut-off, no 80th port normalization
-
+// Some functions for inverted url representation
+// No scheme cut-off, no 80th port normalization
+
void TrspChars(char* s);
void UnTrspChars(char* s);
void TrspChars(char* s, size_t l);
void UnTrspChars(char* s, size_t l);
void TrspChars(const char* s, char* d);
void UnTrspChars(const char* s, char* d);
-
-void InvertDomain(char* begin, char* end);
-
+
+void InvertDomain(char* begin, char* end);
+
inline TString& InvertDomain(TString& url) {
InvertDomain(url.begin(), url.begin() + url.size());
- return url;
-}
-
+ return url;
+}
+
void InvertUrl(char* begin, char* end);
inline void InvertUrl(char* url) {
@@ -27,9 +27,9 @@ inline void InvertUrl(char* url) {
inline TString& InvertUrl(TString& url) {
InvertUrl(url.begin(), url.begin() + url.size());
- return url;
-}
-
+ return url;
+}
+
void RevertUrl(char* begin, char* end);
inline void RevertUrl(char* url) {
@@ -38,5 +38,5 @@ inline void RevertUrl(char* url) {
inline TString& RevertUrl(TString& url) {
RevertUrl(url.begin(), url.begin() + url.size());
- return url;
-}
+ return url;
+}
diff --git a/library/cpp/uri/uri_ut.cpp b/library/cpp/uri/uri_ut.cpp
index 0885defd20..2ebd83fc93 100644
--- a/library/cpp/uri/uri_ut.cpp
+++ b/library/cpp/uri/uri_ut.cpp
@@ -941,7 +941,7 @@ namespace NUri {
TString r;
ProcessQargs(url, r);
return r;
- }
+ }
bool QueryArgsFilter(const TQueryArg& arg, void* filterData) {
const char* skipName = static_cast<const char*>(filterData);