aboutsummaryrefslogtreecommitdiffstats
path: root/util/string
diff options
context:
space:
mode:
authoraosipenko <aosipenko@yandex-team.ru>2022-02-10 16:48:08 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:08 +0300
commit69e3c43df1c96bc2ac8946bf4dfb1f5fc438ff7f (patch)
treeb222e5ac2e2e98872661c51ccceee5da0d291e13 /util/string
parent948fd24d47d4b3b7815aaef1686aea00ef3f4288 (diff)
downloadydb-69e3c43df1c96bc2ac8946bf4dfb1f5fc438ff7f.tar.gz
Restoring authorship annotation for <aosipenko@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/string')
-rw-r--r--util/string/cast.h8
-rw-r--r--util/string/printf_ut.cpp4
-rw-r--r--util/string/strip_ut.cpp6
-rw-r--r--util/string/subst_ut.cpp8
-rw-r--r--util/string/type_ut.cpp10
-rw-r--r--util/string/util.cpp2
-rw-r--r--util/string/util.h18
-rw-r--r--util/string/util_ut.cpp22
-rw-r--r--util/string/vector.cpp2
-rw-r--r--util/string/vector.h12
-rw-r--r--util/string/vector_ut.cpp8
11 files changed, 50 insertions, 50 deletions
diff --git a/util/string/cast.h b/util/string/cast.h
index af827da78b..90e925c194 100644
--- a/util/string/cast.h
+++ b/util/string/cast.h
@@ -165,11 +165,11 @@ inline T FromString(const std::string& s) {
return ::FromString<T>(s.data(), s.size());
}
-template <>
+template <>
inline TString FromString<TString>(const TString& s) {
- return s;
-}
-
+ return s;
+}
+
template <class T>
inline T FromString(const TWtringBuf& s) {
return ::FromString<T, typename TWtringBuf::char_type>(s.data(), s.size());
diff --git a/util/string/printf_ut.cpp b/util/string/printf_ut.cpp
index 1b63d0f8bc..2b2f980b70 100644
--- a/util/string/printf_ut.cpp
+++ b/util/string/printf_ut.cpp
@@ -5,10 +5,10 @@
Y_UNIT_TEST_SUITE(TStringPrintf) {
Y_UNIT_TEST(TestSprintf) {
TString s;
- int len = sprintf(s, "Hello %s", "world");
+ int len = sprintf(s, "Hello %s", "world");
UNIT_ASSERT_EQUAL(s, TString("Hello world"));
UNIT_ASSERT_EQUAL(len, 11);
- }
+ }
Y_UNIT_TEST(TestFcat) {
TString s;
diff --git a/util/string/strip_ut.cpp b/util/string/strip_ut.cpp
index 25b6279863..d1029d1498 100644
--- a/util/string/strip_ut.cpp
+++ b/util/string/strip_ut.cpp
@@ -7,7 +7,7 @@
Y_UNIT_TEST_SUITE(TStripStringTest) {
Y_UNIT_TEST(TestStrip) {
struct TTest {
- const char* Str;
+ const char* Str;
const char* StripLeftRes;
const char* StripRightRes;
const char* StripRes;
@@ -25,7 +25,7 @@ Y_UNIT_TEST_SUITE(TStripStringTest) {
{"abc", "abc", "abc", "abc"},
{"a c", "a c", "a c", "a c"},
};
-
+
for (const auto& test : tests) {
TString inputStr(test.Str);
@@ -41,7 +41,7 @@ Y_UNIT_TEST_SUITE(TStripStringTest) {
UNIT_ASSERT_EQUAL(StripString(inputStrBuf), test.StripRes);
UNIT_ASSERT_EQUAL(StripStringLeft(inputStrBuf), test.StripLeftRes);
UNIT_ASSERT_EQUAL(StripStringRight(inputStrBuf), test.StripRightRes);
- };
+ };
}
Y_UNIT_TEST(TestCustomStrip) {
diff --git a/util/string/subst_ut.cpp b/util/string/subst_ut.cpp
index 940d5195bc..21eccef779 100644
--- a/util/string/subst_ut.cpp
+++ b/util/string/subst_ut.cpp
@@ -121,13 +121,13 @@ Y_UNIT_TEST_SUITE(TStringSubst) {
Y_UNIT_TEST(TestSubstGlobalOld) {
TString s;
- s = "aaa";
+ s = "aaa";
SubstGlobal(s, "a", "bb");
UNIT_ASSERT_EQUAL(s, TString("bbbbbb"));
- s = "aaa";
+ s = "aaa";
SubstGlobal(s, "a", "b");
UNIT_ASSERT_EQUAL(s, TString("bbb"));
- s = "aaa";
+ s = "aaa";
SubstGlobal(s, "a", "");
UNIT_ASSERT_EQUAL(s, TString(""));
s = "abcdefbcbcdfb";
@@ -168,7 +168,7 @@ Y_UNIT_TEST_SUITE(TStringSubst) {
TString s = "aaa";
SubstGlobal(s, 'a', 'b', 1);
UNIT_ASSERT_EQUAL(s, TString("abb"));
- }
+ }
Y_UNIT_TEST(TestSubstCharGlobalRet) {
const TUtf16String w1 = u"abcdabcd";
diff --git a/util/string/type_ut.cpp b/util/string/type_ut.cpp
index daff2a7eec..03e7af62bd 100644
--- a/util/string/type_ut.cpp
+++ b/util/string/type_ut.cpp
@@ -6,11 +6,11 @@
Y_UNIT_TEST_SUITE(TStringClassify) {
Y_UNIT_TEST(TestIsSpace) {
- UNIT_ASSERT_EQUAL(IsSpace(" "), true);
- UNIT_ASSERT_EQUAL(IsSpace("\t\r\n"), true);
- UNIT_ASSERT_EQUAL(IsSpace(""), false);
- UNIT_ASSERT_EQUAL(IsSpace(" a"), false);
- }
+ UNIT_ASSERT_EQUAL(IsSpace(" "), true);
+ UNIT_ASSERT_EQUAL(IsSpace("\t\r\n"), true);
+ UNIT_ASSERT_EQUAL(IsSpace(""), false);
+ UNIT_ASSERT_EQUAL(IsSpace(" a"), false);
+ }
Y_UNIT_TEST(TestIsTrue) {
UNIT_ASSERT(IsTrue("1"));
diff --git a/util/string/util.cpp b/util/string/util.cpp
index 10f265ee00..b14f20bf75 100644
--- a/util/string/util.cpp
+++ b/util/string/util.cpp
@@ -69,4 +69,4 @@ void Tr::Do(TString& str) const {
for (auto it = str.begin() + changePosition; it != str.end(); ++it) {
*it = ConvertChar(*it);
}
-}
+}
diff --git a/util/string/util.h b/util/string/util.h
index 1e173ab75f..0d77a5042b 100644
--- a/util/string/util.h
+++ b/util/string/util.h
@@ -4,7 +4,7 @@
#include <cstring>
#include <cstdarg>
-#include <algorithm>
+#include <algorithm>
#include <util/system/defaults.h>
#include <util/generic/string.h>
@@ -13,7 +13,7 @@
/// @addtogroup Strings_Miscellaneous
/// @{
int a2i(const TString& s);
-
+
/// Removes the last character if it is equal to c.
template <class T>
inline void RemoveIfLast(T& s, int c) {
@@ -170,7 +170,7 @@ public:
*dst = 0;
}
void Do(char* s, size_t l) const {
- for (size_t i = 0; i < l && s[i]; i++)
+ for (size_t i = 0; i < l && s[i]; i++)
s[i] = ConvertChar(s[i]);
}
void Do(TString& str) const;
@@ -180,16 +180,16 @@ private:
size_t FindFirstChangePosition(const TString& str) const;
};
-
-// Removes all occurrences of given character from string
+
+// Removes all occurrences of given character from string
template <typename TStringType>
void RemoveAll(TStringType& str, typename TStringType::char_type ch) {
size_t pos = str.find(ch); // 'find' to avoid cloning of string in 'TString.begin()'
if (pos == TStringType::npos)
- return;
-
+ return;
+
typename TStringType::iterator begin = str.begin();
typename TStringType::iterator end = begin + str.length();
typename TStringType::iterator it = std::remove(begin + pos, end, ch);
- str.erase(it, end);
-}
+ str.erase(it, end);
+}
diff --git a/util/string/util_ut.cpp b/util/string/util_ut.cpp
index 7012e9714c..18a2d8e195 100644
--- a/util/string/util_ut.cpp
+++ b/util/string/util_ut.cpp
@@ -22,25 +22,25 @@ public:
UNIT_ASSERT_EQUAL(strcmp(rul.sep(s1), "+-"), 0);
UNIT_ASSERT_EQUAL(rul.sep(s1), nullptr);
}
-
- void TestRemoveAll() {
- static const struct T {
- const char* Str;
- char Ch;
- const char* Result;
+
+ void TestRemoveAll() {
+ static const struct T {
+ const char* Str;
+ char Ch;
+ const char* Result;
} tests[] = {
{"", 'x', ""},
{"hello world", 'h', "ello world"},
{"hello world", 'l', "heo word"},
{"hello world", 'x', "hello world"},
};
-
+
for (const T* t = tests; t != std::end(tests); ++t) {
TString str(t->Str);
- RemoveAll(str, t->Ch);
- UNIT_ASSERT_EQUAL(t->Result, str);
- }
- }
+ RemoveAll(str, t->Ch);
+ UNIT_ASSERT_EQUAL(t->Result, str);
+ }
+ }
};
UNIT_TEST_SUITE_REGISTRATION(TStrUtilTest);
diff --git a/util/string/vector.cpp b/util/string/vector.cpp
index 963186fe1e..9ba401f0a2 100644
--- a/util/string/vector.cpp
+++ b/util/string/vector.cpp
@@ -88,4 +88,4 @@ TUtf16String JoinStrings(const TVector<TUtf16String>& v, size_t index, size_t co
const size_t l = f + Min(count, v.size() - f);
return JoinStrings(v.begin() + f, v.begin() + l, delim);
-}
+}
diff --git a/util/string/vector.h b/util/string/vector.h
index 8322f349f1..e36c348bbe 100644
--- a/util/string/vector.h
+++ b/util/string/vector.h
@@ -119,14 +119,14 @@ inline TString JoinVectorIntoString(const TVector<T>& v, size_t index, size_t co
TUtf16String JoinStrings(const TVector<TUtf16String>& v, const TWtringBuf delim);
TUtf16String JoinStrings(const TVector<TUtf16String>& v, size_t index, size_t count, const TWtringBuf delim);
-
+
//! Converts vector of strings to vector of type T variables
template <typename T, typename TStringType>
TVector<T> Scan(const TVector<TStringType>& input) {
TVector<T> output;
- output.reserve(input.size());
+ output.reserve(input.size());
for (int i = 0; i < input.ysize(); ++i) {
- output.push_back(FromString<T>(input[i]));
- }
- return output;
-}
+ output.push_back(FromString<T>(input[i]));
+ }
+ return output;
+}
diff --git a/util/string/vector_ut.cpp b/util/string/vector_ut.cpp
index 49ed32497b..817120f268 100644
--- a/util/string/vector_ut.cpp
+++ b/util/string/vector_ut.cpp
@@ -1,5 +1,5 @@
#include <library/cpp/testing/unittest/registar.h>
-#include <util/charset/wide.h>
+#include <util/charset/wide.h>
#include "cast.h"
#include "vector.h"
@@ -28,11 +28,11 @@ Y_UNIT_TEST_SUITE(TStringJoinTest) {
UNIT_ASSERT_EQUAL(JoinStrings(v, 1, 10, ToWtring(" ")), ToWtring("2"));
}
-
+
Y_UNIT_TEST(TestJoinWStrings) {
const TUtf16String str = u"Яндекс";
const TVector<TUtf16String> v(1, str);
-
+
UNIT_ASSERT_EQUAL(JoinStrings(v, TUtf16String()), str);
- }
+ }
}