diff options
author | mvel <mvel@yandex-team.ru> | 2022-02-10 16:45:41 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:41 +0300 |
commit | bd30392c4cc92487950adc375c07adf52da1d592 (patch) | |
tree | e8d1a3f19b7fc890bcef6e4cc5de41f1d88c9ac3 /util/generic | |
parent | 5d50718e66d9c037dc587a0211110b7d25a66185 (diff) | |
download | ydb-bd30392c4cc92487950adc375c07adf52da1d592.tar.gz |
Restoring authorship annotation for <mvel@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/generic')
-rw-r--r-- | util/generic/buffer_ut.cpp | 148 | ||||
-rw-r--r-- | util/generic/guid.h | 18 | ||||
-rw-r--r-- | util/generic/map.h | 2 | ||||
-rw-r--r-- | util/generic/map_ut.cpp | 32 | ||||
-rw-r--r-- | util/generic/ptr.h | 2 | ||||
-rw-r--r-- | util/generic/set.h | 2 | ||||
-rw-r--r-- | util/generic/set_ut.cpp | 8 | ||||
-rw-r--r-- | util/generic/strbase.h | 2 | ||||
-rw-r--r-- | util/generic/strbuf.h | 6 | ||||
-rw-r--r-- | util/generic/strbuf_ut.cpp | 16 | ||||
-rw-r--r-- | util/generic/string_ut.h | 8 | ||||
-rw-r--r-- | util/generic/utility_ut.cpp | 30 |
12 files changed, 137 insertions, 137 deletions
diff --git a/util/generic/buffer_ut.cpp b/util/generic/buffer_ut.cpp index 437d7122ec..d4330dc100 100644 --- a/util/generic/buffer_ut.cpp +++ b/util/generic/buffer_ut.cpp @@ -18,114 +18,114 @@ Y_UNIT_TEST_SUITE(TBufferTest) { } Y_UNIT_TEST(TestAppend) { - const char data[] = "1234567890qwertyuiop"; + const char data[] = "1234567890qwertyuiop"; - TBuffer buf(13); + TBuffer buf(13); TString str; - for (size_t i = 0; i < 10; ++i) { - for (size_t j = 0; j < sizeof(data) - 1; ++j) { - buf.Append(data, j); - buf.Append('q'); - str.append(data, j); - str.append('q'); - } - } + for (size_t i = 0; i < 10; ++i) { + for (size_t j = 0; j < sizeof(data) - 1; ++j) { + buf.Append(data, j); + buf.Append('q'); + str.append(data, j); + str.append('q'); + } + } UNIT_ASSERT_EQUAL(TString(buf.data(), buf.size()), str); } Y_UNIT_TEST(TestReset) { - char content[] = "some text"; - TBuffer buf; + char content[] = "some text"; + TBuffer buf; - buf.Append(content, sizeof(content)); - buf.Clear(); + buf.Append(content, sizeof(content)); + buf.Clear(); - UNIT_ASSERT(buf.Capacity() != 0); + UNIT_ASSERT(buf.Capacity() != 0); - buf.Append(content, sizeof(content)); - buf.Reset(); + buf.Append(content, sizeof(content)); + buf.Reset(); - UNIT_ASSERT_EQUAL(buf.Capacity(), 0); - } + UNIT_ASSERT_EQUAL(buf.Capacity(), 0); + } Y_UNIT_TEST(TestResize) { - char content[] = "some text"; - TBuffer buf; + char content[] = "some text"; + TBuffer buf; - buf.Resize(10); + buf.Resize(10); UNIT_ASSERT_VALUES_EQUAL(buf.size(), 10u); - buf.Resize(0); + buf.Resize(0); UNIT_ASSERT_VALUES_EQUAL(buf.size(), 0u); - buf.Resize(9); + buf.Resize(9); memcpy(buf.data(), content, 9); UNIT_ASSERT_VALUES_EQUAL(TString(buf.data(), buf.size()), "some text"); - buf.Resize(4); + buf.Resize(4); UNIT_ASSERT_VALUES_EQUAL(TString(buf.data(), buf.size()), "some"); - } + } Y_UNIT_TEST(TestReserve) { - TBuffer buf; - UNIT_ASSERT_EQUAL(buf.Capacity(), 0); + TBuffer buf; + UNIT_ASSERT_EQUAL(buf.Capacity(), 0); - buf.Reserve(4); - UNIT_ASSERT_EQUAL(buf.Capacity(), 4); + buf.Reserve(4); + UNIT_ASSERT_EQUAL(buf.Capacity(), 4); - buf.Reserve(6); - UNIT_ASSERT_EQUAL(buf.Capacity(), 8); + buf.Reserve(6); + UNIT_ASSERT_EQUAL(buf.Capacity(), 8); - buf.Reserve(32); - UNIT_ASSERT_EQUAL(buf.Capacity(), 32); + buf.Reserve(32); + UNIT_ASSERT_EQUAL(buf.Capacity(), 32); - buf.Reserve(33); - UNIT_ASSERT_EQUAL(buf.Capacity(), 64); - buf.Reserve(64); - UNIT_ASSERT_EQUAL(buf.Capacity(), 64); + buf.Reserve(33); + UNIT_ASSERT_EQUAL(buf.Capacity(), 64); + buf.Reserve(64); + UNIT_ASSERT_EQUAL(buf.Capacity(), 64); - buf.Resize(128); - UNIT_ASSERT_EQUAL(buf.Capacity(), 128); + buf.Resize(128); + UNIT_ASSERT_EQUAL(buf.Capacity(), 128); - buf.Append('a'); - UNIT_ASSERT_EQUAL(buf.Capacity(), 256); + buf.Append('a'); + UNIT_ASSERT_EQUAL(buf.Capacity(), 256); TString tmp1 = "abcdef"; buf.Append(tmp1.data(), tmp1.size()); - UNIT_ASSERT_EQUAL(buf.Capacity(), 256); + UNIT_ASSERT_EQUAL(buf.Capacity(), 256); TString tmp2 = "30498290sfokdsflj2308w"; - buf.Resize(1020); + buf.Resize(1020); buf.Append(tmp2.data(), tmp2.size()); - UNIT_ASSERT_EQUAL(buf.Capacity(), 2048); - } + UNIT_ASSERT_EQUAL(buf.Capacity(), 2048); + } Y_UNIT_TEST(TestShrinkToFit) { - TBuffer buf; + TBuffer buf; TString content = "some text"; buf.Append(content.data(), content.size()); - UNIT_ASSERT_EQUAL(buf.Size(), 9); - UNIT_ASSERT_EQUAL(buf.Capacity(), 16); + UNIT_ASSERT_EQUAL(buf.Size(), 9); + UNIT_ASSERT_EQUAL(buf.Capacity(), 16); - buf.ShrinkToFit(); - UNIT_ASSERT_EQUAL(buf.Size(), 9); - UNIT_ASSERT_EQUAL(buf.Capacity(), 9); + buf.ShrinkToFit(); + UNIT_ASSERT_EQUAL(buf.Size(), 9); + UNIT_ASSERT_EQUAL(buf.Capacity(), 9); UNIT_ASSERT_EQUAL(TString(buf.data(), buf.size()), content); - const size_t MB = 1024 * 1024; - buf.Resize(MB); - UNIT_ASSERT_EQUAL(buf.Capacity(), MB); - buf.ShrinkToFit(); - UNIT_ASSERT_EQUAL(buf.Capacity(), MB); - buf.Resize(MB + 100); - UNIT_ASSERT_EQUAL(buf.Capacity(), 2 * MB); - buf.ShrinkToFit(); - UNIT_ASSERT_EQUAL(buf.Capacity(), MB + 100); - } - -#if 0 + const size_t MB = 1024 * 1024; + buf.Resize(MB); + UNIT_ASSERT_EQUAL(buf.Capacity(), MB); + buf.ShrinkToFit(); + UNIT_ASSERT_EQUAL(buf.Capacity(), MB); + buf.Resize(MB + 100); + UNIT_ASSERT_EQUAL(buf.Capacity(), 2 * MB); + buf.ShrinkToFit(); + UNIT_ASSERT_EQUAL(buf.Capacity(), MB + 100); + } + +#if 0 Y_UNIT_TEST(TestAlignUp) { char content[] = "some text"; TBuffer buf; @@ -142,9 +142,9 @@ Y_UNIT_TEST(TestAlignUp) { UNIT_ASSERT(buf.Size() % 4 == 0); UNIT_ASSERT_VALUES_EQUAL(TString(~buf, +buf), "some text!!!1234"); } -#endif +#endif -#if 0 +#if 0 Y_UNIT_TEST(TestSpeed) { const char data[] = "1234567890qwertyuiop"; const size_t c = 100000; @@ -177,19 +177,19 @@ Y_UNIT_TEST(TestSpeed) { UNIT_ASSERT(t1 < t2); } -#endif +#endif Y_UNIT_TEST(TestFillAndChop) { - TBuffer buf; - buf.Append("Some ", 5); - buf.Fill('!', 5); - buf.Append(" text.", 6); + TBuffer buf; + buf.Append("Some ", 5); + buf.Fill('!', 5); + buf.Append(" text.", 6); UNIT_ASSERT_VALUES_EQUAL(TString(buf.data(), buf.size()), "Some !!!!! text."); - buf.Chop(5, 6); + buf.Chop(5, 6); UNIT_ASSERT_VALUES_EQUAL(TString(buf.data(), buf.size()), "Some text."); - } - + } + Y_UNIT_TEST(TestComparison) { TBuffer buf1("abcd", 4); TBuffer buf2("abcde", 5); diff --git a/util/generic/guid.h b/util/generic/guid.h index 2bf6c8ad99..d2e884c83b 100644 --- a/util/generic/guid.h +++ b/util/generic/guid.h @@ -4,15 +4,15 @@ #include <util/str_stl.h> -/** - * UUID generation - * - * NOTE: It is not a real GUID (RFC 4122), as described in - * https://en.wikipedia.org/wiki/Universally_unique_identifier - * https://en.wikipedia.org/wiki/Globally_unique_identifier - * - * See https://clubs.at.yandex-team.ru/stackoverflow/10238/10240 - * and https://st.yandex-team.ru/IGNIETFERRO-768 for details. +/** + * UUID generation + * + * NOTE: It is not a real GUID (RFC 4122), as described in + * https://en.wikipedia.org/wiki/Universally_unique_identifier + * https://en.wikipedia.org/wiki/Globally_unique_identifier + * + * See https://clubs.at.yandex-team.ru/stackoverflow/10238/10240 + * and https://st.yandex-team.ru/IGNIETFERRO-768 for details. */ struct TGUID { ui32 dw[4] = {}; diff --git a/util/generic/map.h b/util/generic/map.h index b5001b56c0..140c7668ce 100644 --- a/util/generic/map.h +++ b/util/generic/map.h @@ -37,7 +37,7 @@ public: inline explicit operator bool() const noexcept { return !this->empty(); } - + inline bool contains(const K& key) const { return this->find(key) != this->end(); } diff --git a/util/generic/map_ut.cpp b/util/generic/map_ut.cpp index 79e832b024..7808192e74 100644 --- a/util/generic/map_ut.cpp +++ b/util/generic/map_ut.cpp @@ -5,35 +5,35 @@ #include <algorithm> Y_UNIT_TEST_SUITE(TYMapTest) { - template <typename TAlloc> + template <typename TAlloc> void DoTestMap1(TMap<char, int, TLess<char>, TAlloc>& m); - template <typename TAlloc> + template <typename TAlloc> void DoTestMMap1(TMultiMap<char, int, TLess<char>, TAlloc>& mm); Y_UNIT_TEST(TestMap1) { - { + { TMap<char, int, TLess<char>> m; - DoTestMap1(m); + DoTestMap1(m); } - { - TMemoryPool p(100); + { + TMemoryPool p(100); TMap<char, int, TLess<char>, TPoolAllocator> m(&p); - DoTestMap1(m); - } - } + DoTestMap1(m); + } + } Y_UNIT_TEST(TestMMap1) { - { + { TMultiMap<char, int, TLess<char>> mm; - DoTestMMap1(mm); + DoTestMMap1(mm); } - { - TMemoryPool p(100); + { + TMemoryPool p(100); TMultiMap<char, int, TLess<char>, TPoolAllocator> mm(&p); - DoTestMMap1(mm); - } - } + DoTestMMap1(mm); + } + } template <typename TAlloc> void DoTestMap1(TMap<char, int, TLess<char>, TAlloc>& m) { diff --git a/util/generic/ptr.h b/util/generic/ptr.h index 19db0e3ec5..f75af6f862 100644 --- a/util/generic/ptr.h +++ b/util/generic/ptr.h @@ -1119,7 +1119,7 @@ private: TPtr T_; }; -// saves .Get() on argument passing. Intended usage: Func(TPtrArg<X> p); ... TIntrusivePtr<X> p2; Func(p2); +// saves .Get() on argument passing. Intended usage: Func(TPtrArg<X> p); ... TIntrusivePtr<X> p2; Func(p2); template <class T> class TPtrArg { T* Ptr; diff --git a/util/generic/set.h b/util/generic/set.h index 4c437ca26f..42ecb2759e 100644 --- a/util/generic/set.h +++ b/util/generic/set.h @@ -19,7 +19,7 @@ public: return !this->empty(); } - template <class TheKey> + template <class TheKey> inline bool contains(const TheKey& key) const { return this->find(key) != this->end(); } diff --git a/util/generic/set_ut.cpp b/util/generic/set_ut.cpp index d2769d327f..6a8c503608 100644 --- a/util/generic/set_ut.cpp +++ b/util/generic/set_ut.cpp @@ -77,23 +77,23 @@ Y_UNIT_TEST_SUITE(YSetTest) { TSet<int> const& crs = s; UNIT_ASSERT(!crs.contains(0)); - + s.insert(1); s.insert(42); s.insert(100); s.insert(2); - + UNIT_ASSERT(s.contains(1)); UNIT_ASSERT(s.contains(2)); UNIT_ASSERT(s.contains(42)); UNIT_ASSERT(s.contains(100)); } - + Y_UNIT_TEST(TestBounds) { int array1[] = {1, 3, 6, 7}; TSet<int> s(array1, array1 + sizeof(array1) / sizeof(array1[0])); TSet<int> const& crs = s; - + TSet<int>::iterator sit; TSet<int>::const_iterator scit; std::pair<TSet<int>::iterator, TSet<int>::iterator> pit; diff --git a/util/generic/strbase.h b/util/generic/strbase.h index ab39fc7537..a2b1ec160d 100644 --- a/util/generic/strbase.h +++ b/util/generic/strbase.h @@ -123,7 +123,7 @@ public: return std::basic_string<TCharType, TCharTraits, Allocator>(Ptr(), Len()); } - /** + /** * @param Pointer to character inside the string, or nullptr. * @return Offset from string beginning (in chars), or npos on nullptr. */ diff --git a/util/generic/strbuf.h b/util/generic/strbuf.h index 70b9360d58..d8e38a00c1 100644 --- a/util/generic/strbuf.h +++ b/util/generic/strbuf.h @@ -434,19 +434,19 @@ public: } public: // string subsequences - /// Cut last @c shift characters (or less if length is less than @c shift) + /// Cut last @c shift characters (or less if length is less than @c shift) inline TdSelf& Chop(size_t shift) noexcept { this->remove_suffix(std::min(shift, size())); return *this; } - /// Cut first @c shift characters (or less if length is less than @c shift) + /// Cut first @c shift characters (or less if length is less than @c shift) inline TdSelf& Skip(size_t shift) noexcept { this->remove_prefix(std::min(shift, size())); return *this; } - /// Sets the start pointer to a position relative to the end + /// Sets the start pointer to a position relative to the end inline TdSelf& RSeek(size_t tailSize) noexcept { if (size() > tailSize) { //WARN: removing TStringView:: will lead to an infinite recursion diff --git a/util/generic/strbuf_ut.cpp b/util/generic/strbuf_ut.cpp index 69cde785af..6b6109a06f 100644 --- a/util/generic/strbuf_ut.cpp +++ b/util/generic/strbuf_ut.cpp @@ -56,10 +56,10 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { UNIT_ASSERT_VALUES_EQUAL(str.After('x'), TStringBuf("qwerty")); UNIT_ASSERT_VALUES_EQUAL(str.After('y'), TStringBuf()); UNIT_ASSERT_STRINGS_EQUAL(str.After('='), str); - - // Also works properly on empty strings - TStringBuf empty; - UNIT_ASSERT_STRINGS_EQUAL(empty.After('x'), empty); + + // Also works properly on empty strings + TStringBuf empty; + UNIT_ASSERT_STRINGS_EQUAL(empty.After('x'), empty); } Y_UNIT_TEST(TestBefore) { @@ -168,10 +168,10 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { rt = lt.SplitOff('r'); UNIT_ASSERT_EQUAL(lt, TStringBuf("qwe")); UNIT_ASSERT_EQUAL(rt, TStringBuf("ty")); - - rt = qw; - lt = rt.NextTok('r'); - TStringBuf ty = rt.NextTok('r'); // no 'r' in "ty" + + rt = qw; + lt = rt.NextTok('r'); + TStringBuf ty = rt.NextTok('r'); // no 'r' in "ty" UNIT_ASSERT_EQUAL(rt.size(), 0); UNIT_ASSERT_EQUAL(ty, TStringBuf("ty")); } diff --git a/util/generic/string_ut.h b/util/generic/string_ut.h index 44bb10bdeb..d98106ac1f 100644 --- a/util/generic/string_ut.h +++ b/util/generic/string_ut.h @@ -526,9 +526,9 @@ public: void TestConstructors() { TStringType s0(nullptr); - UNIT_ASSERT(s0.size() == 0); + UNIT_ASSERT(s0.size() == 0); UNIT_ASSERT_EQUAL(s0, TStringType()); - + TStringType s; TStringType s1(*Data._0()); TStringType s2(Data._0()); @@ -895,8 +895,8 @@ public: TStringType sS = s2; // type 'TStringType' is used as is ComputeHash(sS); /*size_t hash_val = sS.hash(); - - try { + + try { //UNIT_ASSERT(hash_val == Data.HashOf_0123456()); } catch (...) { Cerr << hash_val << Endl; diff --git a/util/generic/utility_ut.cpp b/util/generic/utility_ut.cpp index 8e9d5afff9..270f57e64a 100644 --- a/util/generic/utility_ut.cpp +++ b/util/generic/utility_ut.cpp @@ -5,23 +5,23 @@ // DO_NOT_STYLE -class TTest { -public: - inline TTest(int val) - : Val(val) - { - } +class TTest { +public: + inline TTest(int val) + : Val(val) + { + } - inline void Swap(TTest& t) { - DoSwap(Val, t.Val); - } + inline void Swap(TTest& t) { + DoSwap(Val, t.Val); + } - int Val; + int Val; -private: - TTest(const TTest&); - TTest& operator=(const TTest&); -}; +private: + TTest(const TTest&); + TTest& operator=(const TTest&); +}; struct TUnorderedTag { TStringBuf Tag; @@ -34,7 +34,7 @@ static bool operator<(const TUnorderedTag, const TUnorderedTag) { static bool operator>(const TUnorderedTag, const TUnorderedTag) = delete; Y_UNIT_TEST_SUITE(TUtilityTest) { - + Y_UNIT_TEST(TestSwapPrimitive) { int i = 0; int j = 1; |