diff options
author | tobo <tobo@yandex-team.ru> | 2022-02-10 16:47:27 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:27 +0300 |
commit | 7fe839092527589b38f014d854c51565b3c1adfa (patch) | |
tree | 309e97022d3530044b712b8f71318c78faf7856e /util/generic | |
parent | d0d68c395c10da4cb56a1c845504570a04d7893e (diff) | |
download | ydb-7fe839092527589b38f014d854c51565b3c1adfa.tar.gz |
Restoring authorship annotation for <tobo@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/generic')
-rw-r--r-- | util/generic/algorithm_ut.cpp | 48 | ||||
-rw-r--r-- | util/generic/bitops.h | 6 | ||||
-rw-r--r-- | util/generic/bitops_ut.cpp | 2 | ||||
-rw-r--r-- | util/generic/hash.h | 8 | ||||
-rw-r--r-- | util/generic/hash_ut.cpp | 6 | ||||
-rw-r--r-- | util/generic/is_in_ut.cpp | 12 | ||||
-rw-r--r-- | util/generic/iterator_ut.cpp | 4 | ||||
-rw-r--r-- | util/generic/map_ut.cpp | 6 | ||||
-rw-r--r-- | util/generic/maybe.cpp | 12 | ||||
-rw-r--r-- | util/generic/maybe.h | 8 | ||||
-rw-r--r-- | util/generic/maybe_ut.cpp | 10 | ||||
-rw-r--r-- | util/generic/reserve.h | 2 | ||||
-rw-r--r-- | util/generic/strbase.h | 22 | ||||
-rw-r--r-- | util/generic/strbuf_ut.cpp | 60 | ||||
-rw-r--r-- | util/generic/string.h | 4 | ||||
-rw-r--r-- | util/generic/string_transparent_hash_ut.cpp | 2 | ||||
-rw-r--r-- | util/generic/string_ut.cpp | 2 | ||||
-rw-r--r-- | util/generic/string_ut.h | 12 | ||||
-rw-r--r-- | util/generic/typelist.h | 8 | ||||
-rw-r--r-- | util/generic/vector_ut.cpp | 2 | ||||
-rw-r--r-- | util/generic/xrange_ut.cpp | 2 | ||||
-rw-r--r-- | util/generic/yexception.cpp | 6 | ||||
-rw-r--r-- | util/generic/yexception.h | 8 | ||||
-rw-r--r-- | util/generic/yexception_ut.cpp | 6 | ||||
-rw-r--r-- | util/generic/ymath.h | 16 | ||||
-rw-r--r-- | util/generic/ymath_ut.cpp | 24 |
26 files changed, 149 insertions, 149 deletions
diff --git a/util/generic/algorithm_ut.cpp b/util/generic/algorithm_ut.cpp index 8d732fcc0c..c44e3c2224 100644 --- a/util/generic/algorithm_ut.cpp +++ b/util/generic/algorithm_ut.cpp @@ -8,10 +8,10 @@ static auto isOne = [](char c) { return c == '1'; }; Y_UNIT_TEST_SUITE(TAlgorithm) { Y_UNIT_TEST(AnyTest) { - UNIT_ASSERT(0 == AnyOf(TStringBuf("00"), isOne)); - UNIT_ASSERT(1 == AnyOf(TStringBuf("01"), isOne)); - UNIT_ASSERT(1 == AnyOf(TStringBuf("10"), isOne)); - UNIT_ASSERT(1 == AnyOf(TStringBuf("11"), isOne)); + UNIT_ASSERT(0 == AnyOf(TStringBuf("00"), isOne)); + UNIT_ASSERT(1 == AnyOf(TStringBuf("01"), isOne)); + UNIT_ASSERT(1 == AnyOf(TStringBuf("10"), isOne)); + UNIT_ASSERT(1 == AnyOf(TStringBuf("11"), isOne)); UNIT_ASSERT(0 == AnyOf(TStringBuf(), isOne)); const char array00[]{'0', '0'}; @@ -21,10 +21,10 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { } Y_UNIT_TEST(AllOfTest) { - UNIT_ASSERT(0 == AllOf(TStringBuf("00"), isOne)); - UNIT_ASSERT(0 == AllOf(TStringBuf("01"), isOne)); - UNIT_ASSERT(0 == AllOf(TStringBuf("10"), isOne)); - UNIT_ASSERT(1 == AllOf(TStringBuf("11"), isOne)); + UNIT_ASSERT(0 == AllOf(TStringBuf("00"), isOne)); + UNIT_ASSERT(0 == AllOf(TStringBuf("01"), isOne)); + UNIT_ASSERT(0 == AllOf(TStringBuf("10"), isOne)); + UNIT_ASSERT(1 == AllOf(TStringBuf("11"), isOne)); UNIT_ASSERT(1 == AllOf(TStringBuf(), isOne)); const char array01[]{'0', '1'}; @@ -34,11 +34,11 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { } Y_UNIT_TEST(CountIfTest) { - UNIT_ASSERT(3 == CountIf(TStringBuf("____1________1____1_______"), isOne)); - UNIT_ASSERT(5 == CountIf(TStringBuf("1____1________1____1_______1"), isOne)); - UNIT_ASSERT(0 == CountIf(TStringBuf("___________"), isOne)); + UNIT_ASSERT(3 == CountIf(TStringBuf("____1________1____1_______"), isOne)); + UNIT_ASSERT(5 == CountIf(TStringBuf("1____1________1____1_______1"), isOne)); + UNIT_ASSERT(0 == CountIf(TStringBuf("___________"), isOne)); UNIT_ASSERT(0 == CountIf(TStringBuf(), isOne)); - UNIT_ASSERT(1 == CountIf(TStringBuf("1"), isOne)); + UNIT_ASSERT(1 == CountIf(TStringBuf("1"), isOne)); const char array[] = "____1________1____1_______"; UNIT_ASSERT(3 == CountIf(array, isOne)); @@ -46,11 +46,11 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { Y_UNIT_TEST(CountTest) { UNIT_ASSERT(3 == Count("____1________1____1_______", '1')); - UNIT_ASSERT(3 == Count(TStringBuf("____1________1____1_______"), '1')); - UNIT_ASSERT(5 == Count(TStringBuf("1____1________1____1_______1"), '1')); - UNIT_ASSERT(0 == Count(TStringBuf("___________"), '1')); + UNIT_ASSERT(3 == Count(TStringBuf("____1________1____1_______"), '1')); + UNIT_ASSERT(5 == Count(TStringBuf("1____1________1____1_______1"), '1')); + UNIT_ASSERT(0 == Count(TStringBuf("___________"), '1')); UNIT_ASSERT(0 == Count(TStringBuf(), '1')); - UNIT_ASSERT(1 == Count(TStringBuf("1"), '1')); + UNIT_ASSERT(1 == Count(TStringBuf("1"), '1')); const char array[] = "____1________1____1_______"; UNIT_ASSERT(3 == Count(array, '1')); @@ -85,18 +85,18 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), "123", "poi", "xyz"), 1); // TString and TStringBuf - UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), TStringBuf("123"), TStringBuf("poi")), 0); - UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), TStringBuf("123"), TStringBuf("poi"), - TStringBuf("xyz")), + UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), TStringBuf("123"), TStringBuf("poi")), 0); + UNIT_ASSERT_VALUES_EQUAL(CountOf(TString("xyz"), TStringBuf("123"), TStringBuf("poi"), + TStringBuf("xyz")), 1); // TStringBuf and const char * - UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), "123", "poi"), 0); - UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), "123", "poi", "xyz"), 1); + UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), "123", "poi"), 0); + UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), "123", "poi", "xyz"), 1); // TStringBuf and TString - UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), TString("123"), TString("poi")), 0); - UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), TString("123"), TString("poi"), + UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), TString("123"), TString("poi")), 0); + UNIT_ASSERT_VALUES_EQUAL(CountOf(TStringBuf("xyz"), TString("123"), TString("poi"), TString("xyz")), 1); } @@ -151,7 +151,7 @@ Y_UNIT_TEST_SUITE(TAlgorithm) { struct TVectorNoCopy: std::vector<int> { public: - TVectorNoCopy() = default; + TVectorNoCopy() = default; private: TVectorNoCopy(const TVectorNoCopy&); diff --git a/util/generic/bitops.h b/util/generic/bitops.h index 2db15fc59b..28983463a6 100644 --- a/util/generic/bitops.h +++ b/util/generic/bitops.h @@ -81,7 +81,7 @@ namespace NBitOps { value >>= 1; while (value) { value >>= 1; - ++result; + ++result; } return result; @@ -282,7 +282,7 @@ Y_FORCE_INLINE ui64 MostSignificantBit(ui64 v) { ui64 res = 0; if (v) while (v >>= 1) - ++res; + ++res; #endif return res; } @@ -301,7 +301,7 @@ Y_FORCE_INLINE ui64 LeastSignificantBit(ui64 v) { ui64 res = 0; if (v) { while (!(v & 1)) { - ++res; + ++res; v >>= 1; } } diff --git a/util/generic/bitops_ut.cpp b/util/generic/bitops_ut.cpp index d23c2b5c27..018c9bae6e 100644 --- a/util/generic/bitops_ut.cpp +++ b/util/generic/bitops_ut.cpp @@ -36,7 +36,7 @@ static T ReverseBitsSlow(T v) { for (v >>= 1; v; v >>= 1) { r <<= 1; r |= v & 1; - --s; + --s; } r <<= s; // shift when v's highest bits are zero diff --git a/util/generic/hash.h b/util/generic/hash.h index e46db21fa9..1ec3d35677 100644 --- a/util/generic/hash.h +++ b/util/generic/hash.h @@ -77,8 +77,8 @@ struct __yhashtable_iterator { : cur(n) { } /*y*/ - __yhashtable_iterator() = default; - + __yhashtable_iterator() = default; + reference operator*() const { return cur->val; } @@ -961,7 +961,7 @@ __yhashtable_iterator<V>& __yhashtable_iterator<V>::operator++() { if ((uintptr_t)cur & 1) { node** bucket = (node**)((uintptr_t)cur & ~1); while (*bucket == nullptr) - ++bucket; + ++bucket; Y_ASSERT(*bucket != nullptr); cur = (node*)((uintptr_t)*bucket & ~1); } @@ -982,7 +982,7 @@ __yhashtable_const_iterator<V>& __yhashtable_const_iterator<V>::operator++() { if ((uintptr_t)cur & 1) { node** bucket = (node**)((uintptr_t)cur & ~1); while (*bucket == nullptr) - ++bucket; + ++bucket; Y_ASSERT(*bucket != nullptr); cur = (node*)((uintptr_t)*bucket & ~1); } diff --git a/util/generic/hash_ut.cpp b/util/generic/hash_ut.cpp index 0551d58770..0d986dc19b 100644 --- a/util/generic/hash_ut.cpp +++ b/util/generic/hash_ut.cpp @@ -306,7 +306,7 @@ void THashTest::TestHMMap1() { UNIT_ASSERT((*i).first == 'X'); UNIT_ASSERT((*i).second == 10); - ++i; + ++i; UNIT_ASSERT((*i).first == 'X'); UNIT_ASSERT((*i).second == 20); @@ -746,7 +746,7 @@ void THashTest::TestInvariants() { int count1 = 0; for (auto pos = set.begin(); pos != set.end(); pos++) { - ++count1; + ++count1; } UNIT_ASSERT_VALUES_EQUAL(count1, 1000); @@ -1143,7 +1143,7 @@ void THashTest::TestAt() { char key[] = {11, 12, 0, 1, 2, 11, 0}; TEST_AT_THROWN_EXCEPTION(TString, TString, char*, key, "\\x0B\\x0C"); - TEST_AT_THROWN_EXCEPTION(TString, TString, TStringBuf, TStringBuf(key, sizeof(key) - 1), "\\x0B\\x0C\\0\\1\\2\\x0B"); + TEST_AT_THROWN_EXCEPTION(TString, TString, TStringBuf, TStringBuf(key, sizeof(key) - 1), "\\x0B\\x0C\\0\\1\\2\\x0B"); #undef TEST_AT_THROWN_EXCEPTION } diff --git a/util/generic/is_in_ut.cpp b/util/generic/is_in_ut.cpp index c668bce807..ca183a9d5d 100644 --- a/util/generic/is_in_ut.cpp +++ b/util/generic/is_in_ut.cpp @@ -81,12 +81,12 @@ Y_UNIT_TEST_SUITE(TIsIn) { UNIT_ASSERT(IsIn({6}, 6)); UNIT_ASSERT(!IsIn({6}, 7)); UNIT_ASSERT(!IsIn(std::initializer_list<int>(), 6)); - UNIT_ASSERT(IsIn({TStringBuf("abc"), TStringBuf("def")}, TStringBuf("abc"))); - UNIT_ASSERT(IsIn({TStringBuf("abc"), TStringBuf("def")}, TStringBuf("def"))); - UNIT_ASSERT(IsIn({"abc", "def"}, TStringBuf("def"))); + UNIT_ASSERT(IsIn({TStringBuf("abc"), TStringBuf("def")}, TStringBuf("abc"))); + UNIT_ASSERT(IsIn({TStringBuf("abc"), TStringBuf("def")}, TStringBuf("def"))); + UNIT_ASSERT(IsIn({"abc", "def"}, TStringBuf("def"))); UNIT_ASSERT(IsIn({abc, def}, def)); // direct pointer comparison - UNIT_ASSERT(!IsIn({TStringBuf("abc"), TStringBuf("def")}, TStringBuf("ghi"))); - UNIT_ASSERT(!IsIn({"abc", "def"}, TStringBuf("ghi"))); + UNIT_ASSERT(!IsIn({TStringBuf("abc"), TStringBuf("def")}, TStringBuf("ghi"))); + UNIT_ASSERT(!IsIn({"abc", "def"}, TStringBuf("ghi"))); UNIT_ASSERT(!IsIn({"abc", "def"}, TString("ghi"))); const TStringBuf str = "abc////"; @@ -111,6 +111,6 @@ Y_UNIT_TEST_SUITE(TIsIn) { UNIT_ASSERT(IsIn(array, "a")); UNIT_ASSERT(IsIn(array, TString("b"))); UNIT_ASSERT(!IsIn(array, "c")); - UNIT_ASSERT(IsIn(array, TStringBuf("d"))); + UNIT_ASSERT(IsIn(array, TStringBuf("d"))); } } diff --git a/util/generic/iterator_ut.cpp b/util/generic/iterator_ut.cpp index 00be19e10e..6e7494b28c 100644 --- a/util/generic/iterator_ut.cpp +++ b/util/generic/iterator_ut.cpp @@ -52,9 +52,9 @@ Y_UNIT_TEST_SUITE(TInputRangeAdaptor) { }; Y_UNIT_TEST(TUrlPart) { - const TVector<TStringBuf> expected = {TStringBuf("yandex.ru"), TStringBuf("search?")}; + const TVector<TStringBuf> expected = {TStringBuf("yandex.ru"), TStringBuf("search?")}; auto expected_part = expected.begin(); - for (const TStringBuf& part : TUrlPart(TStringBuf("yandex.ru/search?"))) { + for (const TStringBuf& part : TUrlPart(TStringBuf("yandex.ru/search?"))) { UNIT_ASSERT_VALUES_EQUAL(part, *expected_part); ++expected_part; } diff --git a/util/generic/map_ut.cpp b/util/generic/map_ut.cpp index 79e832b024..63f6ae574a 100644 --- a/util/generic/map_ut.cpp +++ b/util/generic/map_ut.cpp @@ -80,13 +80,13 @@ Y_UNIT_TEST_SUITE(TYMapTest) { m.insert(std::pair<const char, int>('Y', 32)); // jbuck: standard way typename mmap::iterator i = m.find('X'); // Find first match. - ++i; + ++i; UNIT_ASSERT((*i).first == 'X'); UNIT_ASSERT((*i).second == 20); - ++i; + ++i; UNIT_ASSERT((*i).first == 'Y'); UNIT_ASSERT((*i).second == 32); - ++i; + ++i; UNIT_ASSERT(i == m.end()); size_t count = m.erase('X'); diff --git a/util/generic/maybe.cpp b/util/generic/maybe.cpp index 43262934f8..6ce4627190 100644 --- a/util/generic/maybe.cpp +++ b/util/generic/maybe.cpp @@ -1,13 +1,13 @@ #include "maybe.h" -#include <util/system/type_name.h> +#include <util/system/type_name.h> -[[noreturn]] void NMaybe::TPolicyUndefinedExcept::OnEmpty(const std::type_info& valueTypeInfo) { - ythrow yexception() << "TMaybe is empty, value type: "sv << TypeName(valueTypeInfo); +[[noreturn]] void NMaybe::TPolicyUndefinedExcept::OnEmpty(const std::type_info& valueTypeInfo) { + ythrow yexception() << "TMaybe is empty, value type: "sv << TypeName(valueTypeInfo); } -[[noreturn]] void NMaybe::TPolicyUndefinedFail::OnEmpty(const std::type_info& valueTypeInfo) { - const TString typeName = TypeName(valueTypeInfo); - Y_FAIL("TMaybe is empty, value type: %s", typeName.c_str()); +[[noreturn]] void NMaybe::TPolicyUndefinedFail::OnEmpty(const std::type_info& valueTypeInfo) { + const TString typeName = TypeName(valueTypeInfo); + Y_FAIL("TMaybe is empty, value type: %s", typeName.c_str()); } template <> diff --git a/util/generic/maybe.h b/util/generic/maybe.h index 34d21aebcd..b1b1a681e5 100644 --- a/util/generic/maybe.h +++ b/util/generic/maybe.h @@ -11,11 +11,11 @@ namespace NMaybe { struct TPolicyUndefinedExcept { - [[noreturn]] static void OnEmpty(const std::type_info& valueTypeInfo); + [[noreturn]] static void OnEmpty(const std::type_info& valueTypeInfo); }; struct TPolicyUndefinedFail { - [[noreturn]] static void OnEmpty(const std::type_info& valueTypeInfo); + [[noreturn]] static void OnEmpty(const std::type_info& valueTypeInfo); }; } @@ -301,7 +301,7 @@ public: void CheckDefined() const { if (Y_UNLIKELY(!Defined())) { - Policy::OnEmpty(typeid(TValueType)); + Policy::OnEmpty(typeid(TValueType)); } } @@ -716,7 +716,7 @@ inline IOutputStream& operator<<(IOutputStream& out, const TMaybe<T, TPolicy>& m if (maybe.Defined()) { out << *maybe; } else { - out << TStringBuf("(empty maybe)"); + out << TStringBuf("(empty maybe)"); } return out; } diff --git a/util/generic/maybe_ut.cpp b/util/generic/maybe_ut.cpp index 2c1a425c5e..1213f7f9f4 100644 --- a/util/generic/maybe_ut.cpp +++ b/util/generic/maybe_ut.cpp @@ -998,9 +998,9 @@ Y_UNIT_TEST_SUITE(TMaybeTest) { UNIT_ASSERT(m.Defined()); UNIT_ASSERT(m->FromMaybeConstructorApplied); } - - Y_UNIT_TEST(TestOnEmptyException) { - TMaybe<TStringBuf> v; - UNIT_ASSERT_EXCEPTION_CONTAINS(v.GetRef(), yexception, "StringBuf"); - } + + Y_UNIT_TEST(TestOnEmptyException) { + TMaybe<TStringBuf> v; + UNIT_ASSERT_EXCEPTION_CONTAINS(v.GetRef(), yexception, "StringBuf"); + } } diff --git a/util/generic/reserve.h b/util/generic/reserve.h index 81ceed19dc..a4610208a4 100644 --- a/util/generic/reserve.h +++ b/util/generic/reserve.h @@ -6,6 +6,6 @@ namespace NDetail { }; } -constexpr ::NDetail::TReserveTag Reserve(size_t capacity) { +constexpr ::NDetail::TReserveTag Reserve(size_t capacity) { return ::NDetail::TReserveTag{capacity}; } diff --git a/util/generic/strbase.h b/util/generic/strbase.h index ab39fc7537..66361b9b27 100644 --- a/util/generic/strbase.h +++ b/util/generic/strbase.h @@ -107,10 +107,10 @@ public: using const_reverse_iterator = TReverseIteratorBase<const_iterator>; static constexpr size_t StrLen(const TCharType* s) noexcept { - if (Y_LIKELY(s)) { + if (Y_LIKELY(s)) { return TTraits::length(s); - } - return 0; + } + return 0; } template <class TCharTraits> @@ -172,7 +172,7 @@ public: return Ptr()[Len() - 1]; } - inline TCharType front() const noexcept { + inline TCharType front() const noexcept { Y_ASSERT(!empty()); return Ptr()[0]; } @@ -261,16 +261,16 @@ public: return s1.AsStringView() == s2.AsStringView(); } - static bool equal(const TSelf& s1, const TCharType* p) noexcept { - if (p == nullptr) { - return s1.Len() == 0; - } - + static bool equal(const TSelf& s1, const TCharType* p) noexcept { + if (p == nullptr) { + return s1.Len() == 0; + } + return s1.AsStringView() == p; } - static bool equal(const TCharType* p, const TSelf& s2) noexcept { - return equal(s2, p); + static bool equal(const TCharType* p, const TSelf& s2) noexcept { + return equal(s2, p); } static bool equal(const TStringView s1, const TStringView s2) noexcept { diff --git a/util/generic/strbuf_ut.cpp b/util/generic/strbuf_ut.cpp index 69cde785af..6daf61a7cf 100644 --- a/util/generic/strbuf_ut.cpp +++ b/util/generic/strbuf_ut.cpp @@ -11,7 +11,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { UNIT_ASSERT_EQUAL(*str.data(), 'q'); UNIT_ASSERT_EQUAL(str.size(), 6); - TStringBuf str1("qwe\0rty"sv); + TStringBuf str1("qwe\0rty"sv); TStringBuf str2(str1.data()); UNIT_ASSERT_VALUES_UNEQUAL(str1, str2); UNIT_ASSERT_VALUES_EQUAL(str1.size(), 7); @@ -30,7 +30,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { Y_UNIT_TEST(TestConstExpr) { static constexpr TStringBuf str1("qwe\0rty", 7); static constexpr TStringBuf str2(str1.data(), str1.size()); - static constexpr TStringBuf str3 = "qwe\0rty"sv; + static constexpr TStringBuf str3 = "qwe\0rty"sv; UNIT_ASSERT_VALUES_EQUAL(str1.size(), 7); @@ -52,8 +52,8 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { Y_UNIT_TEST(TestAfter) { TStringBuf str("qwerty"); - UNIT_ASSERT_VALUES_EQUAL(str.After('w'), TStringBuf("erty")); - UNIT_ASSERT_VALUES_EQUAL(str.After('x'), TStringBuf("qwerty")); + UNIT_ASSERT_VALUES_EQUAL(str.After('w'), TStringBuf("erty")); + UNIT_ASSERT_VALUES_EQUAL(str.After('x'), TStringBuf("qwerty")); UNIT_ASSERT_VALUES_EQUAL(str.After('y'), TStringBuf()); UNIT_ASSERT_STRINGS_EQUAL(str.After('='), str); @@ -65,9 +65,9 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { Y_UNIT_TEST(TestBefore) { TStringBuf str("qwerty"); - UNIT_ASSERT_VALUES_EQUAL(str.Before('w'), TStringBuf("q")); - UNIT_ASSERT_VALUES_EQUAL(str.Before('x'), TStringBuf("qwerty")); - UNIT_ASSERT_VALUES_EQUAL(str.Before('y'), TStringBuf("qwert")); + UNIT_ASSERT_VALUES_EQUAL(str.Before('w'), TStringBuf("q")); + UNIT_ASSERT_VALUES_EQUAL(str.Before('x'), TStringBuf("qwerty")); + UNIT_ASSERT_VALUES_EQUAL(str.Before('y'), TStringBuf("qwert")); UNIT_ASSERT_VALUES_EQUAL(str.Before('q'), TStringBuf()); } @@ -137,7 +137,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { Y_UNIT_TEST(TestEmpty) { UNIT_ASSERT(TStringBuf().empty()); - UNIT_ASSERT(!TStringBuf("q").empty()); + UNIT_ASSERT(!TStringBuf("q").empty()); } Y_UNIT_TEST(TestShift) { @@ -149,10 +149,10 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { UNIT_ASSERT(str.empty()); str = qw; - UNIT_ASSERT_EQUAL(str.SubStr(2), TStringBuf("erty")); + UNIT_ASSERT_EQUAL(str.SubStr(2), TStringBuf("erty")); UNIT_ASSERT_EQUAL(str.Skip(3), qw.SubStr(3)); str.Chop(1); - UNIT_ASSERT_EQUAL(str, TStringBuf("rt")); + UNIT_ASSERT_EQUAL(str, TStringBuf("rt")); } Y_UNIT_TEST(TestSplit) { @@ -161,19 +161,19 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { rt = qw; lt = rt.NextTok('r'); - UNIT_ASSERT_EQUAL(lt, TStringBuf("qwe")); - UNIT_ASSERT_EQUAL(rt, TStringBuf("ty")); + UNIT_ASSERT_EQUAL(lt, TStringBuf("qwe")); + UNIT_ASSERT_EQUAL(rt, TStringBuf("ty")); lt = qw; rt = lt.SplitOff('r'); - UNIT_ASSERT_EQUAL(lt, TStringBuf("qwe")); - UNIT_ASSERT_EQUAL(rt, TStringBuf("ty")); + 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" UNIT_ASSERT_EQUAL(rt.size(), 0); - UNIT_ASSERT_EQUAL(ty, TStringBuf("ty")); + UNIT_ASSERT_EQUAL(ty, TStringBuf("ty")); } Y_UNIT_TEST(TestNextTok) { @@ -187,19 +187,19 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { Y_UNIT_TEST(TestNextStringTok) { TStringBuf buf1("a@@b@@c"); - UNIT_ASSERT_EQUAL(buf1.NextTok("@@"), TStringBuf("a")); - UNIT_ASSERT_EQUAL(buf1.NextTok("@@"), TStringBuf("b")); - UNIT_ASSERT_EQUAL(buf1.NextTok("@@"), TStringBuf("c")); + UNIT_ASSERT_EQUAL(buf1.NextTok("@@"), TStringBuf("a")); + UNIT_ASSERT_EQUAL(buf1.NextTok("@@"), TStringBuf("b")); + UNIT_ASSERT_EQUAL(buf1.NextTok("@@"), TStringBuf("c")); UNIT_ASSERT_EQUAL(buf1, TStringBuf()); TStringBuf buf2("a@@b@@c"); - UNIT_ASSERT_EQUAL(buf2.RNextTok("@@"), TStringBuf("c")); - UNIT_ASSERT_EQUAL(buf2.RNextTok("@@"), TStringBuf("b")); - UNIT_ASSERT_EQUAL(buf2.RNextTok("@@"), TStringBuf("a")); + UNIT_ASSERT_EQUAL(buf2.RNextTok("@@"), TStringBuf("c")); + UNIT_ASSERT_EQUAL(buf2.RNextTok("@@"), TStringBuf("b")); + UNIT_ASSERT_EQUAL(buf2.RNextTok("@@"), TStringBuf("a")); UNIT_ASSERT_EQUAL(buf2, TStringBuf()); TStringBuf buf3("a@@b@@c"); - UNIT_ASSERT_EQUAL(buf3.RNextTok("@@@"), TStringBuf("a@@b@@c")); + UNIT_ASSERT_EQUAL(buf3.RNextTok("@@@"), TStringBuf("a@@b@@c")); UNIT_ASSERT_EQUAL(buf3, TStringBuf()); } @@ -223,7 +223,7 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { } Y_UNIT_TEST(TestRFind) { - TStringBuf buf1 = "123123456"; + TStringBuf buf1 = "123123456"; UNIT_ASSERT_EQUAL(buf1.rfind('3'), 5); UNIT_ASSERT_EQUAL(buf1.rfind('4'), 6); UNIT_ASSERT_EQUAL(buf1.rfind('7'), TStringBuf::npos); @@ -242,11 +242,11 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { Y_UNIT_TEST(TestRNextTok) { TStringBuf buf1("a.b.c"); - UNIT_ASSERT_EQUAL(buf1.RNextTok('.'), TStringBuf("c")); - UNIT_ASSERT_EQUAL(buf1, TStringBuf("a.b")); + UNIT_ASSERT_EQUAL(buf1.RNextTok('.'), TStringBuf("c")); + UNIT_ASSERT_EQUAL(buf1, TStringBuf("a.b")); TStringBuf buf2("a"); - UNIT_ASSERT_EQUAL(buf2.RNextTok('.'), TStringBuf("a")); + UNIT_ASSERT_EQUAL(buf2.RNextTok('.'), TStringBuf("a")); UNIT_ASSERT_EQUAL(buf2, TStringBuf()); TStringBuf buf3("ab cd ef"), tok; @@ -258,12 +258,12 @@ Y_UNIT_TEST_SUITE(TStrBufTest) { Y_UNIT_TEST(TestRSplitOff) { TStringBuf buf1("a.b.c"); - UNIT_ASSERT_EQUAL(buf1.RSplitOff('.'), TStringBuf("a.b")); - UNIT_ASSERT_EQUAL(buf1, TStringBuf("c")); + UNIT_ASSERT_EQUAL(buf1.RSplitOff('.'), TStringBuf("a.b")); + UNIT_ASSERT_EQUAL(buf1, TStringBuf("c")); TStringBuf buf2("a"); UNIT_ASSERT_EQUAL(buf2.RSplitOff('.'), TStringBuf()); - UNIT_ASSERT_EQUAL(buf2, TStringBuf("a")); + UNIT_ASSERT_EQUAL(buf2, TStringBuf("a")); } Y_UNIT_TEST(TestCBeginCEnd) { @@ -352,7 +352,7 @@ Y_UNIT_TEST_SUITE(TWtrBufTest) { Y_UNIT_TEST(TestConstExpr) { static constexpr TWtringBuf str1(u"qwe\0rty", 7); static constexpr TWtringBuf str2(str1.data(), str1.size()); - static constexpr TWtringBuf str3 = u"qwe\0rty"sv; + static constexpr TWtringBuf str3 = u"qwe\0rty"sv; UNIT_ASSERT_VALUES_EQUAL(str1.size(), 7); diff --git a/util/generic/string.h b/util/generic/string.h index 8cd8aa6917..b867f9a9d2 100644 --- a/util/generic/string.h +++ b/util/generic/string.h @@ -205,7 +205,7 @@ protected: return {new TStdStr(std::forward<A>(a)...), typename TStorage::TNoIncrement()}; } - static TStorage Construct() noexcept { + static TStorage Construct() noexcept { return TStdStr::NullStr(); } @@ -372,7 +372,7 @@ public: } // ~~~ Constructor ~~~ : FAMILY0(,TBasicString) - TBasicString() noexcept + TBasicString() noexcept #ifndef TSTRING_IS_STD_STRING : S_(Construct()) #endif diff --git a/util/generic/string_transparent_hash_ut.cpp b/util/generic/string_transparent_hash_ut.cpp index b87fa2843e..10c782e574 100644 --- a/util/generic/string_transparent_hash_ut.cpp +++ b/util/generic/string_transparent_hash_ut.cpp @@ -15,5 +15,5 @@ Y_UNIT_TEST_SUITE(StringHashFunctorTests) { // If either `THash` or `TEqualTo` is not transparent compilation will fail. UNIT_ASSERT_UNEQUAL(s.find(TStringBuf("foo")), s.end()); UNIT_ASSERT_EQUAL(s.find(TStringBuf("bar")), s.end()); - } + } } diff --git a/util/generic/string_ut.cpp b/util/generic/string_ut.cpp index ac82e9091d..e4fbd69c79 100644 --- a/util/generic/string_ut.cpp +++ b/util/generic/string_ut.cpp @@ -724,7 +724,7 @@ protected: class TStringTest: public TTestBase, private TStringTestImpl<TString, TTestData<char>> { public: UNIT_TEST_SUITE(TStringTest); - UNIT_TEST(TestMaxSize); + UNIT_TEST(TestMaxSize); UNIT_TEST(TestConstructors); UNIT_TEST(TestReplace); #ifndef TSTRING_IS_STD_STRING diff --git a/util/generic/string_ut.h b/util/generic/string_ut.h index 44bb10bdeb..4bd0e376c1 100644 --- a/util/generic/string_ut.h +++ b/util/generic/string_ut.h @@ -517,13 +517,13 @@ protected: TTestData Data; public: - void TestMaxSize() { + void TestMaxSize() { const size_t badMaxVal = TStringType{}.max_size() + 1; - - TStringType s; - UNIT_CHECK_GENERATED_EXCEPTION(s.reserve(badMaxVal), std::length_error); - } - + + TStringType s; + UNIT_CHECK_GENERATED_EXCEPTION(s.reserve(badMaxVal), std::length_error); + } + void TestConstructors() { TStringType s0(nullptr); UNIT_ASSERT(s0.size() == 0); diff --git a/util/generic/typelist.h b/util/generic/typelist.h index 5ce26ab97c..19e90159cd 100644 --- a/util/generic/typelist.h +++ b/util/generic/typelist.h @@ -78,12 +78,12 @@ namespace NTL { template <bool isSigned, class T, class TS, class TU> struct TTypeSelectorBase { using TSignedInts = typename TConcat<TTypeList<T>, TS>::type; - using TUnsignedInts = TU; + using TUnsignedInts = TU; }; template <class T, class TS, class TU> struct TTypeSelectorBase<false, T, TS, TU> { - using TSignedInts = TS; + using TSignedInts = TS; using TUnsignedInts = typename TConcat<TTypeList<T>, TU>::type; }; @@ -91,8 +91,8 @@ namespace NTL { struct TTypeSelector: public TTypeSelectorBase<((T)(-1) < 0), T, TS, TU> { }; - using T1 = TTypeSelector<char, TCommonSignedInts, TCommonUnsignedInts>; - using T2 = TTypeSelector<wchar_t, T1::TSignedInts, T1::TUnsignedInts>; + using T1 = TTypeSelector<char, TCommonSignedInts, TCommonUnsignedInts>; + using T2 = TTypeSelector<wchar_t, T1::TSignedInts, T1::TUnsignedInts>; } using TSignedInts = NTL::T2::TSignedInts; diff --git a/util/generic/vector_ut.cpp b/util/generic/vector_ut.cpp index 0f6b4037a0..ce5e00cd83 100644 --- a/util/generic/vector_ut.cpp +++ b/util/generic/vector_ut.cpp @@ -505,7 +505,7 @@ private: template <class TOther> struct rebind { - using other = TDebugAlloc<TOther>; + using other = TDebugAlloc<TOther>; }; }; diff --git a/util/generic/xrange_ut.cpp b/util/generic/xrange_ut.cpp index 8106da03e7..a0c0da7121 100644 --- a/util/generic/xrange_ut.cpp +++ b/util/generic/xrange_ut.cpp @@ -15,7 +15,7 @@ Y_UNIT_TEST_SUITE(XRange) { size_t last = 0; for (auto i : xrange(begin, end)) { - ++count; + ++count; sum += i; last = i; if (!firstInited) { diff --git a/util/generic/yexception.cpp b/util/generic/yexception.cpp index 2ce6c4369d..9744e70e87 100644 --- a/util/generic/yexception.cpp +++ b/util/generic/yexception.cpp @@ -23,7 +23,7 @@ TString CurrentExceptionMessage() { const TBackTrace* bt = e.BackTrace(); if (bt) { - return TString::Join(bt->PrintToString(), TStringBuf("\n"), FormatExc(e)); + return TString::Join(bt->PrintToString(), TStringBuf("\n"), FormatExc(e)); } return FormatExc(e); @@ -70,9 +70,9 @@ std::string CurrentExceptionTypeName() { void TSystemError::Init() { yexception& exc = *this; - exc << TStringBuf("("); + exc << TStringBuf("("); exc << TStringBuf(LastSystemErrorText(Status_)); - exc << TStringBuf(") "); + exc << TStringBuf(") "); } NPrivateException::yexception::yexception() { diff --git a/util/generic/yexception.h b/util/generic/yexception.h index b0c604e8c4..7662c1b639 100644 --- a/util/generic/yexception.h +++ b/util/generic/yexception.h @@ -75,7 +75,7 @@ namespace NPrivateException { template <class T> static inline T&& operator+(const TSourceLocation& sl, T&& t) { - return std::forward<T>(t << sl << TStringBuf(": ")); + return std::forward<T>(t << sl << TStringBuf(": ")); } } @@ -180,7 +180,7 @@ TString FormatExc(const std::exception& exception); if (Y_UNLIKELY(!(CONDITION))) { \ ythrow THROW_EXPRESSION; \ } \ - } while (false) + } while (false) /// @def Y_ENSURE_SIMPLE /// This macro works like the Y_ENSURE, but requires the second argument to be a constant string view. @@ -194,10 +194,10 @@ TString FormatExc(const std::exception& exception); } \ } while (false) -#define Y_ENSURE_IMPL_1(CONDITION) Y_ENSURE_SIMPLE(CONDITION, ::TStringBuf("Condition violated: `" Y_STRINGIZE(CONDITION) "'"), ::NPrivate::ThrowYException) +#define Y_ENSURE_IMPL_1(CONDITION) Y_ENSURE_SIMPLE(CONDITION, ::TStringBuf("Condition violated: `" Y_STRINGIZE(CONDITION) "'"), ::NPrivate::ThrowYException) #define Y_ENSURE_IMPL_2(CONDITION, MESSAGE) Y_ENSURE_EX(CONDITION, yexception() << MESSAGE) -#define Y_ENSURE_BT_IMPL_1(CONDITION) Y_ENSURE_SIMPLE(CONDITION, ::TStringBuf("Condition violated: `" Y_STRINGIZE(CONDITION) "'"), ::NPrivate::ThrowYExceptionWithBacktrace) +#define Y_ENSURE_BT_IMPL_1(CONDITION) Y_ENSURE_SIMPLE(CONDITION, ::TStringBuf("Condition violated: `" Y_STRINGIZE(CONDITION) "'"), ::NPrivate::ThrowYExceptionWithBacktrace) #define Y_ENSURE_BT_IMPL_2(CONDITION, MESSAGE) Y_ENSURE_EX(CONDITION, TWithBackTrace<yexception>() << MESSAGE) /** diff --git a/util/generic/yexception_ut.cpp b/util/generic/yexception_ut.cpp index cb3e29fed8..0e113cdd45 100644 --- a/util/generic/yexception_ut.cpp +++ b/util/generic/yexception_ut.cpp @@ -29,9 +29,9 @@ static void CallbackFun(int i) { static IOutputStream* OUTS = nullptr; -namespace NOuter::NInner { - void Compare10And20() { - Y_ENSURE(10 > 20); +namespace NOuter::NInner { + void Compare10And20() { + Y_ENSURE(10 > 20); } } diff --git a/util/generic/ymath.h b/util/generic/ymath.h index 9ff9ae2abe..067f091a32 100644 --- a/util/generic/ymath.h +++ b/util/generic/ymath.h @@ -56,14 +56,14 @@ static constexpr T Sqr(const T t) noexcept { return t * t; } -inline double Sigmoid(double x) { - return 1.0 / (1.0 + std::exp(-x)); -} - -inline float Sigmoid(float x) { - return 1.0f / (1.0f + std::exp(-x)); -} - +inline double Sigmoid(double x) { + return 1.0 / (1.0 + std::exp(-x)); +} + +inline float Sigmoid(float x) { + return 1.0f / (1.0f + std::exp(-x)); +} + static inline bool IsFinite(double f) { #if defined(isfinite) return isfinite(f); diff --git a/util/generic/ymath_ut.cpp b/util/generic/ymath_ut.cpp index 29190b55eb..86294e9e1b 100644 --- a/util/generic/ymath_ut.cpp +++ b/util/generic/ymath_ut.cpp @@ -33,7 +33,7 @@ class TMathTest: public TTestBase { UNIT_TEST(TestIsValidFloat); UNIT_TEST(TestAbs); UNIT_TEST(TestPower); - UNIT_TEST(TestSigmoid); + UNIT_TEST(TestSigmoid); UNIT_TEST(TestCeilDiv); UNIT_TEST_SUITE_END(); @@ -44,7 +44,7 @@ private: void TestLogGamma(); void TestAbs(); void TestPower(); - void TestSigmoid(); + void TestSigmoid(); void TestCeilDiv(); inline void TestIsValidFloat() { @@ -181,16 +181,16 @@ void TMathTest::TestPower() { UNIT_ASSERT_DOUBLES_EQUAL(Power(0.0, 0), 1.0, 1e-9); UNIT_ASSERT_DOUBLES_EQUAL(Power(0.1, 3), 1e-3, 1e-9); } - -void TMathTest::TestSigmoid() { - UNIT_ASSERT_EQUAL(Sigmoid(0.f), 0.5f); - UNIT_ASSERT_EQUAL(Sigmoid(-5000.f), 0.0f); - UNIT_ASSERT_EQUAL(Sigmoid(5000.f), 1.0f); - - UNIT_ASSERT_EQUAL(Sigmoid(0.), 0.5); - UNIT_ASSERT_EQUAL(Sigmoid(-5000.), 0.0); - UNIT_ASSERT_EQUAL(Sigmoid(5000.), 1.0); -} + +void TMathTest::TestSigmoid() { + UNIT_ASSERT_EQUAL(Sigmoid(0.f), 0.5f); + UNIT_ASSERT_EQUAL(Sigmoid(-5000.f), 0.0f); + UNIT_ASSERT_EQUAL(Sigmoid(5000.f), 1.0f); + + UNIT_ASSERT_EQUAL(Sigmoid(0.), 0.5); + UNIT_ASSERT_EQUAL(Sigmoid(-5000.), 0.0); + UNIT_ASSERT_EQUAL(Sigmoid(5000.), 1.0); +} void TMathTest::TestCeilDiv() { UNIT_ASSERT_VALUES_EQUAL(CeilDiv<ui8>(2, 3), 1); |