diff options
author | Vasily Gerasimov <UgnineSirdis@gmail.com> | 2022-02-10 16:49:10 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:10 +0300 |
commit | 1eb755fbca92172a6aec2f57371b2b3a19dfab43 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /util/string | |
parent | 6cdc8f140213c595e4ad38bc3d97fcef1146b8c3 (diff) | |
download | ydb-1eb755fbca92172a6aec2f57371b2b3a19dfab43.tar.gz |
Restoring authorship annotation for Vasily Gerasimov <UgnineSirdis@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'util/string')
-rw-r--r-- | util/string/builder.h | 12 | ||||
-rw-r--r-- | util/string/builder_ut.cpp | 40 | ||||
-rw-r--r-- | util/string/cast_ut.cpp | 12 | ||||
-rw-r--r-- | util/string/strip.h | 20 | ||||
-rw-r--r-- | util/string/subst_ut.cpp | 6 |
5 files changed, 45 insertions, 45 deletions
diff --git a/util/string/builder.h b/util/string/builder.h index 11eb840e23..7b54821151 100644 --- a/util/string/builder.h +++ b/util/string/builder.h @@ -4,14 +4,14 @@ #include <utility> #include <util/generic/string.h> -namespace NPrivateStringBuilder { +namespace NPrivateStringBuilder { class TStringBuilder: public TString { public: inline TStringBuilder() : Out(*this) { } - + TStringBuilder(TStringBuilder&& rhs) : TString(std::move(rhs)) , Out(*this) @@ -31,9 +31,9 @@ namespace NPrivateStringBuilder { template <class T> static inline TStringBuilder&& operator<<(TStringBuilder&& builder, const T& t) { builder.Out << t; - + return std::move(builder); } -} - -using TStringBuilder = NPrivateStringBuilder::TStringBuilder; +} + +using TStringBuilder = NPrivateStringBuilder::TStringBuilder; diff --git a/util/string/builder_ut.cpp b/util/string/builder_ut.cpp index 28777c87c1..22def683ec 100644 --- a/util/string/builder_ut.cpp +++ b/util/string/builder_ut.cpp @@ -37,27 +37,27 @@ Y_UNIT_TEST_SUITE(TStringBuilderTest) { out << sb; TestEquals("a", s); } - + Y_UNIT_TEST(TestStringBuilderRValue) { - struct TRValueAcceptTester { + struct TRValueAcceptTester { static bool IsRValue(const TString&) { - return false; - } - + return false; + } + static bool IsRValue(TString&&) { - return true; - } - }; - - UNIT_ASSERT(TRValueAcceptTester::IsRValue(TStringBuilder() << "a" << 1)); - - TStringBuilder b; - UNIT_ASSERT(!TRValueAcceptTester::IsRValue(b << "a" << 1)); - TStringBuilder b2; - UNIT_ASSERT(!TRValueAcceptTester::IsRValue(b2 << "a" << 1 << TStringBuilder() << "a")); - UNIT_ASSERT_VALUES_EQUAL("a1a", b2); - - UNIT_ASSERT(TRValueAcceptTester::IsRValue(TStringBuilder() << b2)); - UNIT_ASSERT_VALUES_EQUAL("a1a", TStringBuilder() << b2); - } + return true; + } + }; + + UNIT_ASSERT(TRValueAcceptTester::IsRValue(TStringBuilder() << "a" << 1)); + + TStringBuilder b; + UNIT_ASSERT(!TRValueAcceptTester::IsRValue(b << "a" << 1)); + TStringBuilder b2; + UNIT_ASSERT(!TRValueAcceptTester::IsRValue(b2 << "a" << 1 << TStringBuilder() << "a")); + UNIT_ASSERT_VALUES_EQUAL("a1a", b2); + + UNIT_ASSERT(TRValueAcceptTester::IsRValue(TStringBuilder() << b2)); + UNIT_ASSERT_VALUES_EQUAL("a1a", TStringBuilder() << b2); + } } diff --git a/util/string/cast_ut.cpp b/util/string/cast_ut.cpp index 4e53d6bf7a..033450c38c 100644 --- a/util/string/cast_ut.cpp +++ b/util/string/cast_ut.cpp @@ -5,8 +5,8 @@ #include <util/charset/wide.h> #include <util/system/defaults.h> -#include <limits> - +#include <limits> + // positive test (return true or no exception) #define test1(t, v) \ F<t>().CheckTryOK(v); \ @@ -279,14 +279,14 @@ Y_UNIT_TEST_SUITE(TCastTest) { UNIT_ASSERT_VALUES_EQUAL(FloatToString(1.2345678901234567), "1.2345678901234567"); // no truncation UNIT_ASSERT_VALUES_EQUAL(FloatToString(5e-324), "5e-324"); // denormalized UNIT_ASSERT_VALUES_EQUAL(FloatToString(-0.0), "-0"); // sign must be preserved - - UNIT_ASSERT_STRINGS_EQUAL(FloatToString(std::numeric_limits<double>::quiet_NaN()), "nan"); - UNIT_ASSERT_STRINGS_EQUAL(FloatToString(std::numeric_limits<double>::infinity()), "inf"); + + UNIT_ASSERT_STRINGS_EQUAL(FloatToString(std::numeric_limits<double>::quiet_NaN()), "nan"); + UNIT_ASSERT_STRINGS_EQUAL(FloatToString(std::numeric_limits<double>::infinity()), "inf"); UNIT_ASSERT_STRINGS_EQUAL(FloatToString(-std::numeric_limits<double>::infinity()), "-inf"); UNIT_ASSERT_STRINGS_EQUAL(FloatToString(std::numeric_limits<float>::quiet_NaN()), "nan"); UNIT_ASSERT_STRINGS_EQUAL(FloatToString(std::numeric_limits<float>::infinity()), "inf"); - UNIT_ASSERT_STRINGS_EQUAL(FloatToString(-std::numeric_limits<float>::infinity()), "-inf"); + UNIT_ASSERT_STRINGS_EQUAL(FloatToString(-std::numeric_limits<float>::infinity()), "-inf"); } Y_UNIT_TEST(TestReadFloats) { diff --git a/util/string/strip.h b/util/string/strip.h index c9172ef19a..d5ef6da96d 100644 --- a/util/string/strip.h +++ b/util/string/strip.h @@ -69,11 +69,11 @@ struct TStripImpl { const size_t oldLen = e - b; if (stripBeg) { - StripRangeBegin(b, e, criterion); + StripRangeBegin(b, e, criterion); } if (stripEnd) { - StripRangeEnd(b, e, criterion); + StripRangeEnd(b, e, criterion); } const size_t newLen = e - b; @@ -85,7 +85,7 @@ struct TStripImpl { auto b = from.begin(); auto e = from.end(); - if (StripRange(b, e, criterion)) { + if (StripRange(b, e, criterion)) { to = T(b, e - b); return true; @@ -99,7 +99,7 @@ struct TStripImpl { template <class T, class TStripCriterion> static inline T StripString(const T& from, TStripCriterion&& criterion) { T ret; - StripString(from, ret, criterion); + StripString(from, ret, criterion); return ret; } @@ -111,7 +111,7 @@ struct TStripImpl { template <class It, class TStripCriterion> inline bool StripRange(It& b, It& e, TStripCriterion&& criterion) noexcept { - return TStripImpl<true, true>::StripRange(b, e, criterion); + return TStripImpl<true, true>::StripRange(b, e, criterion); } template <class It> @@ -123,7 +123,7 @@ template <class It, class TStripCriterion> inline bool Strip(It& b, size_t& len, TStripCriterion&& criterion) noexcept { It e = b + len; - if (StripRange(b, e, criterion)) { + if (StripRange(b, e, criterion)) { len = e - b; return true; @@ -139,7 +139,7 @@ inline bool Strip(It& b, size_t& len) noexcept { template <class T, class TStripCriterion> static inline bool StripString(const T& from, T& to, TStripCriterion&& criterion) { - return TStripImpl<true, true>::StripString(from, to, criterion); + return TStripImpl<true, true>::StripString(from, to, criterion); } template <class T> @@ -149,7 +149,7 @@ static inline bool StripString(const T& from, T& to) { template <class T, class TStripCriterion> static inline T StripString(const T& from, TStripCriterion&& criterion) { - return TStripImpl<true, true>::StripString(from, criterion); + return TStripImpl<true, true>::StripString(from, criterion); } template <class T> @@ -169,12 +169,12 @@ static inline T StripStringRight(const T& from) { template <class T, class TStripCriterion> static inline T StripStringLeft(const T& from, TStripCriterion&& criterion) { - return TStripImpl<true, false>::StripString(from, criterion); + return TStripImpl<true, false>::StripString(from, criterion); } template <class T, class TStripCriterion> static inline T StripStringRight(const T& from, TStripCriterion&& criterion) { - return TStripImpl<false, true>::StripString(from, criterion); + return TStripImpl<false, true>::StripString(from, criterion); } /// Copies the given string removing leading and trailing spaces. diff --git a/util/string/subst_ut.cpp b/util/string/subst_ut.cpp index 60ea6aabba..21eccef779 100644 --- a/util/string/subst_ut.cpp +++ b/util/string/subst_ut.cpp @@ -130,8 +130,8 @@ Y_UNIT_TEST_SUITE(TStringSubst) { s = "aaa"; SubstGlobal(s, "a", ""); UNIT_ASSERT_EQUAL(s, TString("")); - s = "abcdefbcbcdfb"; - SubstGlobal(s, "bc", "bbc", 2); + s = "abcdefbcbcdfb"; + SubstGlobal(s, "bc", "bbc", 2); UNIT_ASSERT_EQUAL(s, TString("abcdefbbcbbcdfb")); s = "Москва ~ Париж"; SubstGlobal(s, " ~ ", " "); @@ -166,7 +166,7 @@ Y_UNIT_TEST_SUITE(TStringSubst) { UNIT_ASSERT_EQUAL(w, u"abcdaBcd"); TString s = "aaa"; - SubstGlobal(s, 'a', 'b', 1); + SubstGlobal(s, 'a', 'b', 1); UNIT_ASSERT_EQUAL(s, TString("abb")); } |