aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorsobols <sobols@yandex-team.ru>2022-02-10 16:47:08 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:08 +0300
commit09961b69c61f471ddd594e0fd877df62a8021562 (patch)
tree54a7b60a9526a7104557a033eb0a8d70d64b604c /util
parent4ce8835206f981afa4a61915a49a21fb750416ec (diff)
downloadydb-09961b69c61f471ddd594e0fd877df62a8021562.tar.gz
Restoring authorship annotation for <sobols@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util')
-rw-r--r--util/charset/benchmark/utf8_to_wide/main.cpp2
-rw-r--r--util/datetime/base.h8
-rw-r--r--util/datetime/base_ut.cpp22
-rw-r--r--util/draft/datetime.cpp30
-rw-r--r--util/draft/datetime.h6
-rw-r--r--util/draft/datetime_ut.cpp34
-rw-r--r--util/generic/strbuf_ut.cpp46
-rw-r--r--util/generic/string_ut.cpp36
-rw-r--r--util/network/socket.cpp18
-rw-r--r--util/network/socket.h2
-rw-r--r--util/stream/ios_ut.cpp86
-rw-r--r--util/stream/output.cpp64
-rw-r--r--util/string/cast.cpp4
-rw-r--r--util/string/cast_ut.cpp62
-rw-r--r--util/string/escape.cpp10
-rw-r--r--util/string/escape_ut.cpp6
-rw-r--r--util/string/split_ut.cpp22
-rw-r--r--util/string/strip_ut.cpp4
-rw-r--r--util/string/subst_ut.cpp8
-rw-r--r--util/string/type_ut.cpp24
-rw-r--r--util/string/vector_ut.cpp2
-rw-r--r--util/system/types.h8
22 files changed, 252 insertions, 252 deletions
diff --git a/util/charset/benchmark/utf8_to_wide/main.cpp b/util/charset/benchmark/utf8_to_wide/main.cpp
index 09fa567fe5..e9e0d9e612 100644
--- a/util/charset/benchmark/utf8_to_wide/main.cpp
+++ b/util/charset/benchmark/utf8_to_wide/main.cpp
@@ -26,7 +26,7 @@ namespace {
unsigned char* textEnd = data.begin();
for (size_t i = 0; i < N; ++i) {
size_t runeLen;
- WriteUTF8Char(RandomNumber<ui32>(0x7FF) + 1, runeLen, textEnd);
+ WriteUTF8Char(RandomNumber<ui32>(0x7FF) + 1, runeLen, textEnd);
textEnd += runeLen;
}
assign(reinterpret_cast<const char*>(data.begin()), reinterpret_cast<const char*>(textEnd));
diff --git a/util/datetime/base.h b/util/datetime/base.h
index 5e902b8f63..c1529a1793 100644
--- a/util/datetime/base.h
+++ b/util/datetime/base.h
@@ -123,10 +123,10 @@ public:
return Value_ * (1 / 1000000.0);
}
- constexpr double MillisecondsFloat() const noexcept {
- return Value_ * (1 / 1000.0);
- }
-
+ constexpr double MillisecondsFloat() const noexcept {
+ return Value_ * (1 / 1000.0);
+ }
+
constexpr TValue MicroSeconds() const noexcept {
return Value_;
}
diff --git a/util/datetime/base_ut.cpp b/util/datetime/base_ut.cpp
index afc3f802eb..49313d60de 100644
--- a/util/datetime/base_ut.cpp
+++ b/util/datetime/base_ut.cpp
@@ -448,17 +448,17 @@ Y_UNIT_TEST_SUITE(DateTimeTest) {
UNIT_ASSERT_DOUBLES_EQUAL(TDuration::Minutes(1) / TDuration::Seconds(10), 6.0, 1e-9);
}
- Y_UNIT_TEST(TestDurationGetters) {
- const TDuration value = TDuration::MicroSeconds(1234567);
- UNIT_ASSERT_VALUES_EQUAL(value.Seconds(), 1);
- UNIT_ASSERT_DOUBLES_EQUAL(value.SecondsFloat(), 1.234567, 1e-9);
-
- UNIT_ASSERT_VALUES_EQUAL(value.MilliSeconds(), 1234);
- UNIT_ASSERT_DOUBLES_EQUAL(value.MillisecondsFloat(), 1234.567, 1e-9);
-
- UNIT_ASSERT_VALUES_EQUAL(value.MicroSeconds(), 1234567);
- }
-
+ Y_UNIT_TEST(TestDurationGetters) {
+ const TDuration value = TDuration::MicroSeconds(1234567);
+ UNIT_ASSERT_VALUES_EQUAL(value.Seconds(), 1);
+ UNIT_ASSERT_DOUBLES_EQUAL(value.SecondsFloat(), 1.234567, 1e-9);
+
+ UNIT_ASSERT_VALUES_EQUAL(value.MilliSeconds(), 1234);
+ UNIT_ASSERT_DOUBLES_EQUAL(value.MillisecondsFloat(), 1234.567, 1e-9);
+
+ UNIT_ASSERT_VALUES_EQUAL(value.MicroSeconds(), 1234567);
+ }
+
template <class T>
void TestTimeUnits() {
T withTime = T::MicroSeconds(1249571946000000L);
diff --git a/util/draft/datetime.cpp b/util/draft/datetime.cpp
index 5cbe7d8847..aebbec25d3 100644
--- a/util/draft/datetime.cpp
+++ b/util/draft/datetime.cpp
@@ -17,25 +17,25 @@ namespace NDatetime {
{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} //leap
};
- const ui32 MonthDaysNewYear[2][13] = {
- {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}, //nleap
- {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366} //leap
+ const ui32 MonthDaysNewYear[2][13] = {
+ {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}, //nleap
+ {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366} //leap
};
- void YDayToMonthAndDay(ui32 yday, bool isleap, ui32* month, ui32* mday) {
- const ui32* begin = MonthDaysNewYear[isleap] + 1;
- const ui32* end = begin + 12;
- // [31, ..., 365] or [31, ..., 366] (12 elements)
-
- const ui32* pos = UpperBound(begin, end, yday);
+ void YDayToMonthAndDay(ui32 yday, bool isleap, ui32* month, ui32* mday) {
+ const ui32* begin = MonthDaysNewYear[isleap] + 1;
+ const ui32* end = begin + 12;
+ // [31, ..., 365] or [31, ..., 366] (12 elements)
+
+ const ui32* pos = UpperBound(begin, end, yday);
Y_ENSURE(pos != end, "day no. " << yday << " does not exist in " << (isleap ? "leap" : "non-leap") << " year");
-
- *month = pos - begin;
- *mday = yday - *(pos - 1) + 1;
-
+
+ *month = pos - begin;
+ *mday = yday - *(pos - 1) + 1;
+
Y_ASSERT((*month < 12) && (1 <= *mday) && (*mday <= MonthDays[isleap][*month]));
- }
-
+ }
+
struct TTimeData {
i32 IsDst = 0;
i32 GMTOff = 0;
diff --git a/util/draft/datetime.h b/util/draft/datetime.h
index 8a387ea6f1..8f84d13132 100644
--- a/util/draft/datetime.h
+++ b/util/draft/datetime.h
@@ -12,7 +12,7 @@
namespace NDatetime {
extern const ui32 MonthDays[2][12]; // !leapYear; !!leapYear
- extern const ui32 MonthDaysNewYear[2][13]; // !leapYear; !!leapYear
+ extern const ui32 MonthDaysNewYear[2][13]; // !leapYear; !!leapYear
inline ui32 YearDaysAD(ui32 year) {
year = Max<ui32>(year, 1) - 1; //1 AD comes straight after 1 BC, no 0 AD
@@ -27,8 +27,8 @@ namespace NDatetime {
return MonthDaysNewYear[isleap][Min(month, (ui32)11u)] + mday - 1;
}
- void YDayToMonthAndDay(ui32 yday /*0 - based*/, bool isleap, ui32* month /*0 - based*/, ui32* mday /*1 - based*/);
-
+ void YDayToMonthAndDay(ui32 yday /*0 - based*/, bool isleap, ui32* month /*0 - based*/, ui32* mday /*1 - based*/);
+
struct TSimpleTM {
enum EField {
F_NONE = 0,
diff --git a/util/draft/datetime_ut.cpp b/util/draft/datetime_ut.cpp
index a5e065ef6e..da103dace6 100644
--- a/util/draft/datetime_ut.cpp
+++ b/util/draft/datetime_ut.cpp
@@ -62,23 +62,23 @@ Y_UNIT_TEST_SUITE(TSimpleTMTest) {
}
Y_UNIT_TEST(TestYDayConversion) {
- using namespace NDatetime;
- ui32 month;
- ui32 mday;
-
- for (ui32 yday = 0; yday < 365; ++yday) {
- YDayToMonthAndDay(yday, false, &month, &mday);
- UNIT_ASSERT_VALUES_EQUAL(yday, YDayFromMonthAndDay(month, mday, false));
- }
- for (ui32 yday = 0; yday < 366; ++yday) {
- YDayToMonthAndDay(yday, true, &month, &mday);
- UNIT_ASSERT_VALUES_EQUAL(yday, YDayFromMonthAndDay(month, mday, true));
- }
-
- UNIT_ASSERT_EXCEPTION(YDayToMonthAndDay(365, false, &month, &mday), yexception);
- UNIT_ASSERT_EXCEPTION(YDayToMonthAndDay(366, true, &month, &mday), yexception);
- }
-
+ using namespace NDatetime;
+ ui32 month;
+ ui32 mday;
+
+ for (ui32 yday = 0; yday < 365; ++yday) {
+ YDayToMonthAndDay(yday, false, &month, &mday);
+ UNIT_ASSERT_VALUES_EQUAL(yday, YDayFromMonthAndDay(month, mday, false));
+ }
+ for (ui32 yday = 0; yday < 366; ++yday) {
+ YDayToMonthAndDay(yday, true, &month, &mday);
+ UNIT_ASSERT_VALUES_EQUAL(yday, YDayFromMonthAndDay(month, mday, true));
+ }
+
+ UNIT_ASSERT_EXCEPTION(YDayToMonthAndDay(365, false, &month, &mday), yexception);
+ UNIT_ASSERT_EXCEPTION(YDayToMonthAndDay(366, true, &month, &mday), yexception);
+ }
+
Y_UNIT_TEST(SimpleTMTest) {
using namespace NDatetime;
diff --git a/util/generic/strbuf_ut.cpp b/util/generic/strbuf_ut.cpp
index 69cde785af..65f431d1a3 100644
--- a/util/generic/strbuf_ut.cpp
+++ b/util/generic/strbuf_ut.cpp
@@ -347,27 +347,27 @@ Y_UNIT_TEST_SUITE(TStrBufTest) {
UNIT_ASSERT_STRINGS_EQUAL(s, "");
}
}
-
-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());
+
+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;
-
- UNIT_ASSERT_VALUES_EQUAL(str1.size(), 7);
-
- UNIT_ASSERT_VALUES_EQUAL(str1, str2);
- UNIT_ASSERT_VALUES_EQUAL(str2, str3);
- UNIT_ASSERT_VALUES_EQUAL(str1, str3);
-
- static constexpr std::u16string_view view1(str1);
- UNIT_ASSERT_VALUES_EQUAL(str1, view1);
- static_assert(str1.data() == view1.data());
- static_assert(str1.size() == view1.size());
-
- static constexpr TWtringBuf str4(view1);
- UNIT_ASSERT_VALUES_EQUAL(str1, str4);
- static_assert(str1.data() == str4.data());
- static_assert(str1.size() == str4.size());
- }
-}
+
+ UNIT_ASSERT_VALUES_EQUAL(str1.size(), 7);
+
+ UNIT_ASSERT_VALUES_EQUAL(str1, str2);
+ UNIT_ASSERT_VALUES_EQUAL(str2, str3);
+ UNIT_ASSERT_VALUES_EQUAL(str1, str3);
+
+ static constexpr std::u16string_view view1(str1);
+ UNIT_ASSERT_VALUES_EQUAL(str1, view1);
+ static_assert(str1.data() == view1.data());
+ static_assert(str1.size() == view1.size());
+
+ static constexpr TWtringBuf str4(view1);
+ UNIT_ASSERT_VALUES_EQUAL(str1, str4);
+ static_assert(str1.data() == str4.data());
+ static_assert(str1.size() == str4.size());
+ }
+}
diff --git a/util/generic/string_ut.cpp b/util/generic/string_ut.cpp
index ac82e9091d..61855f9b0b 100644
--- a/util/generic/string_ut.cpp
+++ b/util/generic/string_ut.cpp
@@ -811,7 +811,7 @@ public:
UNIT_TEST(TestDecodingMethods);
UNIT_TEST(TestIterators);
UNIT_TEST(TestReverseIterators);
- UNIT_TEST(TestStringLiterals);
+ UNIT_TEST(TestStringLiterals);
UNIT_TEST_SUITE_END();
private:
@@ -895,14 +895,14 @@ private:
str = hello;
UNIT_ASSERT(str == hello);
}
-
- void TestStringLiterals() {
- TUtf16String s1 = u"hello";
- UNIT_ASSERT_VALUES_EQUAL(s1, TUtf16String::FromAscii("hello"));
-
- TUtf16String s2 = u"привет";
- UNIT_ASSERT_VALUES_EQUAL(s2, TUtf16String::FromUtf8("привет"));
- }
+
+ void TestStringLiterals() {
+ TUtf16String s1 = u"hello";
+ UNIT_ASSERT_VALUES_EQUAL(s1, TUtf16String::FromAscii("hello"));
+
+ TUtf16String s2 = u"привет";
+ UNIT_ASSERT_VALUES_EQUAL(s2, TUtf16String::FromUtf8("привет"));
+ }
};
UNIT_TEST_SUITE_REGISTRATION(TWideStringTest);
@@ -936,7 +936,7 @@ public:
UNIT_TEST(TestDecodingMethodsMixedStr);
UNIT_TEST(TestIterators);
UNIT_TEST(TestReverseIterators);
- UNIT_TEST(TestStringLiterals);
+ UNIT_TEST(TestStringLiterals);
UNIT_TEST_SUITE_END();
private:
@@ -1093,14 +1093,14 @@ private:
str = hello;
UNIT_ASSERT(str == hello);
}
-
- void TestStringLiterals() {
- TUtf32String s1 = U"hello";
- UNIT_ASSERT_VALUES_EQUAL(s1, TUtf32String::FromAscii("hello"));
-
- TUtf32String s2 = U"привет";
- UNIT_ASSERT_VALUES_EQUAL(s2, TUtf32String::FromUtf8("привет"));
- }
+
+ void TestStringLiterals() {
+ TUtf32String s1 = U"hello";
+ UNIT_ASSERT_VALUES_EQUAL(s1, TUtf32String::FromAscii("hello"));
+
+ TUtf32String s2 = U"привет";
+ UNIT_ASSERT_VALUES_EQUAL(s2, TUtf32String::FromUtf8("привет"));
+ }
};
UNIT_TEST_SUITE_REGISTRATION(TUtf32StringTest);
diff --git a/util/network/socket.cpp b/util/network/socket.cpp
index 4f6e804346..15a663c524 100644
--- a/util/network/socket.cpp
+++ b/util/network/socket.cpp
@@ -423,15 +423,15 @@ void SetSocketToS(SOCKET s, int tos) {
SetSocketToS(s, &addr, tos);
}
-void SetSocketPriority(SOCKET s, int priority) {
-#if defined(SO_PRIORITY)
- CheckedSetSockOpt(s, SOL_SOCKET, SO_PRIORITY, priority, "priority");
-#else
- Y_UNUSED(s);
- Y_UNUSED(priority);
-#endif
-}
-
+void SetSocketPriority(SOCKET s, int priority) {
+#if defined(SO_PRIORITY)
+ CheckedSetSockOpt(s, SOL_SOCKET, SO_PRIORITY, priority, "priority");
+#else
+ Y_UNUSED(s);
+ Y_UNUSED(priority);
+#endif
+}
+
bool HasLocalAddress(SOCKET socket) {
TOpaqueAddr localAddr;
if (getsockname(socket, localAddr.MutableAddr(), localAddr.LenPtr()) != 0) {
diff --git a/util/network/socket.h b/util/network/socket.h
index 40c8648b40..b4690bebe1 100644
--- a/util/network/socket.h
+++ b/util/network/socket.h
@@ -116,7 +116,7 @@ void SetSocketToS(SOCKET s, int tos);
void SetSocketToS(SOCKET s, const NAddr::IRemoteAddr* addr, int tos);
int GetSocketToS(SOCKET s);
int GetSocketToS(SOCKET s, const NAddr::IRemoteAddr* addr);
-void SetSocketPriority(SOCKET s, int priority);
+void SetSocketPriority(SOCKET s, int priority);
void SetTcpFastOpen(SOCKET s, int qlen);
/**
* Deprecated, consider using HasSocketDataToRead instead.
diff --git a/util/stream/ios_ut.cpp b/util/stream/ios_ut.cpp
index 139f4296e5..9600edf228 100644
--- a/util/stream/ios_ut.cpp
+++ b/util/stream/ios_ut.cpp
@@ -27,9 +27,9 @@ class TStreamsTest: public TTestBase {
UNIT_TEST(TestReadTo);
UNIT_TEST(TestWtrokaOutput);
UNIT_TEST(TestIStreamOperators);
- UNIT_TEST(TestWchar16Output);
- UNIT_TEST(TestWchar32Output);
- UNIT_TEST(TestUtf16StingOutputByChars);
+ UNIT_TEST(TestWchar16Output);
+ UNIT_TEST(TestWchar32Output);
+ UNIT_TEST(TestUtf16StingOutputByChars);
UNIT_TEST_SUITE_END();
public:
@@ -45,9 +45,9 @@ public:
void TestWtrokaOutput();
void TestIStreamOperators();
void TestReadTo();
- void TestWchar16Output();
- void TestWchar32Output();
- void TestUtf16StingOutputByChars();
+ void TestWchar16Output();
+ void TestWchar32Output();
+ void TestUtf16StingOutputByChars();
};
UNIT_TEST_SUITE_REGISTRATION(TStreamsTest);
@@ -450,48 +450,48 @@ void TStreamsTest::TestWtrokaOutput() {
UNIT_ASSERT(s == Text);
}
-
-void TStreamsTest::TestWchar16Output() {
- TString s;
- TStringOutput os(s);
- os << wchar16(97); // latin a
+
+void TStreamsTest::TestWchar16Output() {
+ TString s;
+ TStringOutput os(s);
+ os << wchar16(97); // latin a
os << u'\u044E'; // cyrillic ю
- os << u'я';
- os << wchar16(0xD801); // high surrogate is printed as replacement character U+FFFD
- os << u'b';
-
+ os << u'я';
+ os << wchar16(0xD801); // high surrogate is printed as replacement character U+FFFD
+ os << u'b';
+
UNIT_ASSERT_VALUES_EQUAL(s, "aюя"
"\xEF\xBF\xBD"
"b");
-}
-
-void TStreamsTest::TestWchar32Output() {
- TString s;
- TStringOutput os(s);
- os << wchar32(97); // latin a
+}
+
+void TStreamsTest::TestWchar32Output() {
+ TString s;
+ TStringOutput os(s);
+ os << wchar32(97); // latin a
os << U'\u044E'; // cyrillic ю
- os << U'я';
- os << U'\U0001F600'; // grinning face
- os << u'b';
-
+ os << U'я';
+ os << U'\U0001F600'; // grinning face
+ os << u'b';
+
UNIT_ASSERT_VALUES_EQUAL(s, "aюя"
"\xF0\x9F\x98\x80"
"b");
-}
-
-void TStreamsTest::TestUtf16StingOutputByChars() {
- TString s = "\xd1\x87\xd0\xb8\xd1\x81\xd1\x82\xd0\xb8\xd1\x87\xd0\xb8\xd1\x81\xd1\x82\xd0\xb8";
- TUtf16String w = UTF8ToWide(s);
-
- UNIT_ASSERT_VALUES_EQUAL(w.size(), 10);
-
- TStringStream stream0;
- stream0 << w;
- UNIT_ASSERT_VALUES_EQUAL(stream0.Str(), s);
-
- TStringStream stream1;
- for (size_t i = 0; i < 10; i++) {
- stream1 << w[i];
- }
- UNIT_ASSERT_VALUES_EQUAL(stream1.Str(), s);
-}
+}
+
+void TStreamsTest::TestUtf16StingOutputByChars() {
+ TString s = "\xd1\x87\xd0\xb8\xd1\x81\xd1\x82\xd0\xb8\xd1\x87\xd0\xb8\xd1\x81\xd1\x82\xd0\xb8";
+ TUtf16String w = UTF8ToWide(s);
+
+ UNIT_ASSERT_VALUES_EQUAL(w.size(), 10);
+
+ TStringStream stream0;
+ stream0 << w;
+ UNIT_ASSERT_VALUES_EQUAL(stream0.Str(), s);
+
+ TStringStream stream1;
+ for (size_t i = 0; i < 10; i++) {
+ stream1 << w[i];
+ }
+ UNIT_ASSERT_VALUES_EQUAL(stream1.Str(), s);
+}
diff --git a/util/stream/output.cpp b/util/stream/output.cpp
index db81b81b70..552a58eff7 100644
--- a/util/stream/output.cpp
+++ b/util/stream/output.cpp
@@ -5,7 +5,7 @@
#include <util/memory/tempbuf.h>
#include <util/generic/singleton.h>
#include <util/generic/yexception.h>
-#include <util/charset/utf8.h>
+#include <util/charset/utf8.h>
#include <util/charset/wide.h>
#if defined(_android_)
@@ -24,8 +24,8 @@
#include <io.h>
#endif
-constexpr size_t MAX_UTF8_BYTES = 4; // UTF-8-encoded code point takes between 1 and 4 bytes
-
+constexpr size_t MAX_UTF8_BYTES = 4; // UTF-8-encoded code point takes between 1 and 4 bytes
+
IOutputStream::IOutputStream() noexcept = default;
IOutputStream::~IOutputStream() = default;
@@ -52,25 +52,25 @@ void IOutputStream::DoWriteC(char ch) {
DoWrite(&ch, 1);
}
-template <>
-void Out<wchar16>(IOutputStream& o, wchar16 ch) {
- const wchar32 w32ch = ReadSymbol(&ch, &ch + 1);
- size_t length;
- unsigned char buffer[MAX_UTF8_BYTES];
- WriteUTF8Char(w32ch, length, buffer);
- o.Write(buffer, length);
-}
-
-template <>
-void Out<wchar32>(IOutputStream& o, wchar32 ch) {
- size_t length;
- unsigned char buffer[MAX_UTF8_BYTES];
- WriteUTF8Char(ch, length, buffer);
- o.Write(buffer, length);
-}
-
+template <>
+void Out<wchar16>(IOutputStream& o, wchar16 ch) {
+ const wchar32 w32ch = ReadSymbol(&ch, &ch + 1);
+ size_t length;
+ unsigned char buffer[MAX_UTF8_BYTES];
+ WriteUTF8Char(w32ch, length, buffer);
+ o.Write(buffer, length);
+}
+
+template <>
+void Out<wchar32>(IOutputStream& o, wchar32 ch) {
+ size_t length;
+ unsigned char buffer[MAX_UTF8_BYTES];
+ WriteUTF8Char(ch, length, buffer);
+ o.Write(buffer, length);
+}
+
static void WriteString(IOutputStream& o, const wchar16* w, size_t n) {
- const size_t buflen = (n * MAX_UTF8_BYTES); // * 4 because the conversion functions can convert unicode character into maximum 4 bytes of UTF8
+ const size_t buflen = (n * MAX_UTF8_BYTES); // * 4 because the conversion functions can convert unicode character into maximum 4 bytes of UTF8
TTempBuf buffer(buflen + 1);
char* const data = buffer.Data();
size_t written = 0;
@@ -80,7 +80,7 @@ static void WriteString(IOutputStream& o, const wchar16* w, size_t n) {
}
static void WriteString(IOutputStream& o, const wchar32* w, size_t n) {
- const size_t buflen = (n * MAX_UTF8_BYTES); // * 4 because the conversion functions can convert unicode character into maximum 4 bytes of UTF8
+ const size_t buflen = (n * MAX_UTF8_BYTES); // * 4 because the conversion functions can convert unicode character into maximum 4 bytes of UTF8
TTempBuf buffer(buflen + 1);
char* const data = buffer.Data();
size_t written = 0;
@@ -105,16 +105,16 @@ void Out<std::string_view>(IOutputStream& o, const std::string_view& p) {
}
template <>
-void Out<std::u16string_view>(IOutputStream& o, const std::u16string_view& p) {
- WriteString(o, p.data(), p.length());
-}
-
-template <>
-void Out<std::u32string_view>(IOutputStream& o, const std::u32string_view& p) {
- WriteString(o, p.data(), p.length());
-}
-
-template <>
+void Out<std::u16string_view>(IOutputStream& o, const std::u16string_view& p) {
+ WriteString(o, p.data(), p.length());
+}
+
+template <>
+void Out<std::u32string_view>(IOutputStream& o, const std::u32string_view& p) {
+ WriteString(o, p.data(), p.length());
+}
+
+template <>
void Out<TStringBuf>(IOutputStream& o, const TStringBuf& p) {
o.Write(p.data(), p.length());
}
diff --git a/util/string/cast.cpp b/util/string/cast.cpp
index aa1e65a8e9..75e80dbd3c 100644
--- a/util/string/cast.cpp
+++ b/util/string/cast.cpp
@@ -455,8 +455,8 @@ using TWCharIType = std::conditional_t<std::is_signed<wchar_t>::value, i64, ui64
DEF_INT_SPEC_I(char, TCharIType)
DEF_INT_SPEC_I(wchar_t, TWCharIType)
-DEF_INT_SPEC_I(wchar16, ui64) // wchar16 is always unsigned
-DEF_INT_SPEC_I(wchar32, ui64) // wchar32 is always unsigned
+DEF_INT_SPEC_I(wchar16, ui64) // wchar16 is always unsigned
+DEF_INT_SPEC_I(wchar32, ui64) // wchar32 is always unsigned
#undef DEF_INT_SPEC
#undef DEF_INT_SPEC_I
diff --git a/util/string/cast_ut.cpp b/util/string/cast_ut.cpp
index 033450c38c..1c124aeb4e 100644
--- a/util/string/cast_ut.cpp
+++ b/util/string/cast_ut.cpp
@@ -350,13 +350,13 @@ Y_UNIT_TEST_SUITE(TCastTest) {
#endif
Y_UNIT_TEST(TestWide) {
- TUtf16String iw = u"-100500";
+ TUtf16String iw = u"-100500";
int iv = 0;
UNIT_ASSERT_VALUES_EQUAL(TryFromString(iw, iv), true);
UNIT_ASSERT_VALUES_EQUAL(iv, -100500);
ui64 uv = 0;
- TUtf16String uw = u"21474836470";
+ TUtf16String uw = u"21474836470";
UNIT_ASSERT_VALUES_EQUAL(TryFromString(uw, uv), true);
UNIT_ASSERT_VALUES_EQUAL(uv, 21474836470ull);
@@ -413,7 +413,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
int res2 = 0;
const int def2 = -6;
- TUtf16String s3 = u"-100500";
+ TUtf16String s3 = u"-100500";
UNIT_ASSERT_VALUES_EQUAL(TryFromStringWithDefault(s3, res2, def2), true);
UNIT_ASSERT_VALUES_EQUAL(res2, -100500);
@@ -424,7 +424,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
UNIT_ASSERT_VALUES_EQUAL(FromStringWithDefault(s3, def2), -100500);
UNIT_ASSERT_VALUES_EQUAL(FromStringWithDefault<size_t>(s3), size_t());
- TUtf16String s4 = u"-f100500";
+ TUtf16String s4 = u"-f100500";
UNIT_ASSERT_VALUES_EQUAL(TryFromStringWithDefault(s4, res2, def2), false);
UNIT_ASSERT_VALUES_EQUAL(res2, def2);
@@ -456,12 +456,12 @@ Y_UNIT_TEST_SUITE(TCastTest) {
UNIT_ASSERT_DOUBLES_EQUAL((float)FromString(TString("10E-5")), 10E-5, EPS);
UNIT_ASSERT_VALUES_EQUAL((bool)FromString("da"), true);
UNIT_ASSERT_VALUES_EQUAL((bool)FromString("no"), false);
- UNIT_ASSERT_VALUES_EQUAL((short)FromString(u"9000"), 9000);
- UNIT_ASSERT_VALUES_EQUAL((int)FromString(u"-100500"), -100500);
- UNIT_ASSERT_VALUES_EQUAL((unsigned long long)FromString(TWtringBuf(u"42", 1)), 4);
+ UNIT_ASSERT_VALUES_EQUAL((short)FromString(u"9000"), 9000);
+ UNIT_ASSERT_VALUES_EQUAL((int)FromString(u"-100500"), -100500);
+ UNIT_ASSERT_VALUES_EQUAL((unsigned long long)FromString(TWtringBuf(u"42", 1)), 4);
int integer = FromString("125");
- ui16 wideCharacterCode = FromString(u"125");
- UNIT_ASSERT_VALUES_EQUAL(integer, wideCharacterCode);
+ ui16 wideCharacterCode = FromString(u"125");
+ UNIT_ASSERT_VALUES_EQUAL(integer, wideCharacterCode);
}
static void CheckMessage(TFromStringException& exc, const TString& phrase) {
@@ -530,7 +530,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
UNIT_ASSERT_VALUES_EQUAL(empty, out);
}
{
- const auto hello = u"hello";
+ const auto hello = u"hello";
TWtringBuf out;
UNIT_ASSERT(TryFromString(hello, out));
UNIT_ASSERT_VALUES_EQUAL(hello, out);
@@ -578,25 +578,25 @@ Y_UNIT_TEST_SUITE(TCastTest) {
UNIT_ASSERT_VALUES_EQUAL(ToString(87423.2031250000001), "87423.20313");
UNIT_ASSERT_VALUES_EQUAL(FloatToString(1.0e60, PREC_POINT_DIGITS_STRIP_ZEROES, 0), "1e+60");
}
-
- Y_UNIT_TEST(TestChar) {
- // Given a character ch, ToString(ch) returns
- // the decimal representation of its integral value
-
- // char
- UNIT_ASSERT_VALUES_EQUAL(ToString('\0'), "0");
- UNIT_ASSERT_VALUES_EQUAL(ToString('0'), "48");
-
- // wchar16
- UNIT_ASSERT_VALUES_EQUAL(ToString(u'\0'), "0");
- UNIT_ASSERT_VALUES_EQUAL(ToString(u'0'), "48");
- UNIT_ASSERT_VALUES_EQUAL(ToString(u'я'), "1103");
- UNIT_ASSERT_VALUES_EQUAL(ToString(u'\uFFFF'), "65535");
-
- // wchar32
- UNIT_ASSERT_VALUES_EQUAL(ToString(U'\0'), "0");
- UNIT_ASSERT_VALUES_EQUAL(ToString(U'0'), "48");
- UNIT_ASSERT_VALUES_EQUAL(ToString(U'я'), "1103");
- UNIT_ASSERT_VALUES_EQUAL(ToString(U'\U0001F600'), "128512"); // 'GRINNING FACE' (U+1F600)
- }
+
+ Y_UNIT_TEST(TestChar) {
+ // Given a character ch, ToString(ch) returns
+ // the decimal representation of its integral value
+
+ // char
+ UNIT_ASSERT_VALUES_EQUAL(ToString('\0'), "0");
+ UNIT_ASSERT_VALUES_EQUAL(ToString('0'), "48");
+
+ // wchar16
+ UNIT_ASSERT_VALUES_EQUAL(ToString(u'\0'), "0");
+ UNIT_ASSERT_VALUES_EQUAL(ToString(u'0'), "48");
+ UNIT_ASSERT_VALUES_EQUAL(ToString(u'я'), "1103");
+ UNIT_ASSERT_VALUES_EQUAL(ToString(u'\uFFFF'), "65535");
+
+ // wchar32
+ UNIT_ASSERT_VALUES_EQUAL(ToString(U'\0'), "0");
+ UNIT_ASSERT_VALUES_EQUAL(ToString(U'0'), "48");
+ UNIT_ASSERT_VALUES_EQUAL(ToString(U'я'), "1103");
+ UNIT_ASSERT_VALUES_EQUAL(ToString(U'\U0001F600'), "128512"); // 'GRINNING FACE' (U+1F600)
+ }
};
diff --git a/util/string/escape.cpp b/util/string/escape.cpp
index cd09a7dbd0..e448d4cf1a 100644
--- a/util/string/escape.cpp
+++ b/util/string/escape.cpp
@@ -179,7 +179,7 @@ template TUtf16String& EscapeCImpl<TUtf16String::TChar>(const TUtf16String::TCha
namespace {
template <class TStr>
- inline void AppendUnicode(TStr& s, wchar32 v) {
+ inline void AppendUnicode(TStr& s, wchar32 v) {
char buf[10];
size_t sz = 0;
@@ -187,7 +187,7 @@ namespace {
s.AppendNoAlias(buf, sz);
}
- inline void AppendUnicode(TUtf16String& s, wchar32 v) {
+ inline void AppendUnicode(TUtf16String& s, wchar32 v) {
WriteSymbol(v, s);
}
@@ -264,12 +264,12 @@ static TStr& DoUnescapeC(const TChar* p, size_t sz, TStr& res) {
res.append('\v');
break;
case 'u': {
- ui16 cp[2];
+ ui16 cp[2];
if (ParseHex<4>(p + 1, pe, cp[0])) {
if (Y_UNLIKELY(cp[0] >= 0xD800 && cp[0] <= 0xDBFF && ParseHex<4>(p + 7, pe, cp[1]) && p[5] == '\\' && p[6] == 'u')) {
- const wchar16 wbuf[] = {wchar16(cp[0]), wchar16(cp[1])};
- AppendUnicode(res, ReadSymbol(wbuf, wbuf + 2));
+ const wchar16 wbuf[] = {wchar16(cp[0]), wchar16(cp[1])};
+ AppendUnicode(res, ReadSymbol(wbuf, wbuf + 2));
p += 10;
} else {
AppendUnicode(res, (wchar32)cp[0]);
diff --git a/util/string/escape_ut.cpp b/util/string/escape_ut.cpp
index cd38ecffd3..110546be71 100644
--- a/util/string/escape_ut.cpp
+++ b/util/string/escape_ut.cpp
@@ -90,9 +90,9 @@ Y_UNIT_TEST_SUITE(TEscapeCTest) {
UNIT_ASSERT_VALUES_EQUAL(source, actual2);
}
- UNIT_ASSERT_VALUES_EQUAL(u"http://ya.ru/\\x17\\n\\u1234", EscapeC(u"http://ya.ru/\x17\n\u1234"));
- UNIT_ASSERT_VALUES_EQUAL(u"h", EscapeC(u'h'));
- UNIT_ASSERT_VALUES_EQUAL(u"\\xFF", EscapeC(wchar16(255)));
+ UNIT_ASSERT_VALUES_EQUAL(u"http://ya.ru/\\x17\\n\\u1234", EscapeC(u"http://ya.ru/\x17\n\u1234"));
+ UNIT_ASSERT_VALUES_EQUAL(u"h", EscapeC(u'h'));
+ UNIT_ASSERT_VALUES_EQUAL(u"\\xFF", EscapeC(wchar16(255)));
}
Y_UNIT_TEST(TestEscapeTrigraphs) {
diff --git a/util/string/split_ut.cpp b/util/string/split_ut.cpp
index 43e59f2d75..a1ae92779a 100644
--- a/util/string/split_ut.cpp
+++ b/util/string/split_ut.cpp
@@ -131,8 +131,8 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
}
Y_UNIT_TEST(TestWideSingleDelimiter) {
- TUtf16String data(u"qw ab qwabcab");
- TUtf16String canonic[] = {u"qw", u"ab", TUtf16String(), u"qwabcab"};
+ TUtf16String data(u"qw ab qwabcab");
+ TUtf16String canonic[] = {u"qw", u"ab", TUtf16String(), u"qwabcab"};
TVector<TUtf16String> good(canonic, canonic + 4);
TCharDelimiter<const wchar16> delim(' ');
@@ -188,10 +188,10 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
}
Y_UNIT_TEST(TestWideStringDelimiter) {
- TUtf16String data(u"qw ab qwababcab");
- TUtf16String canonic[] = {u"qw ", u" qw", TUtf16String(), u"c", TUtf16String()};
+ TUtf16String data(u"qw ab qwababcab");
+ TUtf16String canonic[] = {u"qw ", u" qw", TUtf16String(), u"c", TUtf16String()};
TVector<TUtf16String> good(canonic, canonic + 5);
- TUtf16String wideDelim(u"ab");
+ TUtf16String wideDelim(u"ab");
TStringDelimiter<const wchar16> delim(wideDelim.data());
TestDelimiterOnString<TContainerConsumer>(good, data.data(), delim);
@@ -209,20 +209,20 @@ Y_UNIT_TEST_SUITE(SplitStringTest) {
}
Y_UNIT_TEST(TestWideSetDelimiter) {
- TUtf16String data(u"qw ab qwababccab");
- TUtf16String canonic[] = {u"q", u" ab q", u"abab", TUtf16String(), u"ab"};
+ TUtf16String data(u"qw ab qwababccab");
+ TUtf16String canonic[] = {u"q", u" ab q", u"abab", TUtf16String(), u"ab"};
TVector<TUtf16String> good(canonic, canonic + 5);
- TUtf16String wideDelim(u"wc");
+ TUtf16String wideDelim(u"wc");
TSetDelimiter<const wchar16> delim(wideDelim.data());
TestDelimiterOnString<TContainerConsumer>(good, data.data(), delim);
}
Y_UNIT_TEST(TestWideSetDelimiterRange) {
- TUtf16String data(u"qw ab qwababccab");
- TUtf16String canonic[] = {u"q", u" ab q", u"abab", TUtf16String(), u"ab"};
+ TUtf16String data(u"qw ab qwababccab");
+ TUtf16String canonic[] = {u"q", u" ab q", u"abab", TUtf16String(), u"ab"};
TVector<TUtf16String> good(1);
- TUtf16String wideDelim(u"wc");
+ TUtf16String wideDelim(u"wc");
TSetDelimiter<const wchar16> delim(wideDelim.data());
TVector<TUtf16String> test;
diff --git a/util/string/strip_ut.cpp b/util/string/strip_ut.cpp
index d1029d1498..34adeb9a19 100644
--- a/util/string/strip_ut.cpp
+++ b/util/string/strip_ut.cpp
@@ -103,8 +103,8 @@ Y_UNIT_TEST_SUITE(TStripStringTest) {
UNIT_ASSERT_EQUAL(
StripString(
TWtringBuf(u"/abc/"),
- EqualsStripAdapter(u'/')),
- u"abc");
+ EqualsStripAdapter(u'/')),
+ u"abc");
}
Y_UNIT_TEST(TestCollapse) {
diff --git a/util/string/subst_ut.cpp b/util/string/subst_ut.cpp
index 21eccef779..284d54c095 100644
--- a/util/string/subst_ut.cpp
+++ b/util/string/subst_ut.cpp
@@ -161,9 +161,9 @@ Y_UNIT_TEST_SUITE(TStringSubst) {
}
Y_UNIT_TEST(TestSubstCharGlobal) {
- TUtf16String w = u"abcdabcd";
+ TUtf16String w = u"abcdabcd";
SubstGlobal(w, wchar16('b'), wchar16('B'), 3);
- UNIT_ASSERT_EQUAL(w, u"abcdaBcd");
+ UNIT_ASSERT_EQUAL(w, u"abcdaBcd");
TString s = "aaa";
SubstGlobal(s, 'a', 'b', 1);
@@ -171,9 +171,9 @@ Y_UNIT_TEST_SUITE(TStringSubst) {
}
Y_UNIT_TEST(TestSubstCharGlobalRet) {
- const TUtf16String w1 = u"abcdabcd";
+ const TUtf16String w1 = u"abcdabcd";
const TUtf16String w2 = SubstGlobalCopy(w1, wchar16('b'), wchar16('B'), 3);
- UNIT_ASSERT_EQUAL(w2, u"abcdaBcd");
+ UNIT_ASSERT_EQUAL(w2, u"abcdaBcd");
const TString s1 = "aaa";
const TString s2 = SubstGlobalCopy(s1, 'a', 'b', 1);
diff --git a/util/string/type_ut.cpp b/util/string/type_ut.cpp
index 03e7af62bd..890f7062d9 100644
--- a/util/string/type_ut.cpp
+++ b/util/string/type_ut.cpp
@@ -47,11 +47,11 @@ Y_UNIT_TEST_SUITE(TStringClassify) {
UNIT_ASSERT(!IsNumber("foobar"));
UNIT_ASSERT(!IsNumber(""));
- UNIT_ASSERT(IsNumber(u"0"));
- UNIT_ASSERT(IsNumber(u"12345678901234567890"));
- UNIT_ASSERT(!IsNumber(u"1234567890a"));
- UNIT_ASSERT(!IsNumber(u"12345xx67890a"));
- UNIT_ASSERT(!IsNumber(u"foobar"));
+ UNIT_ASSERT(IsNumber(u"0"));
+ UNIT_ASSERT(IsNumber(u"12345678901234567890"));
+ UNIT_ASSERT(!IsNumber(u"1234567890a"));
+ UNIT_ASSERT(!IsNumber(u"12345xx67890a"));
+ UNIT_ASSERT(!IsNumber(u"foobar"));
}
Y_UNIT_TEST(TestIsHexNumber) {
@@ -64,13 +64,13 @@ Y_UNIT_TEST_SUITE(TStringClassify) {
UNIT_ASSERT(!IsHexNumber("foobar"));
UNIT_ASSERT(!IsHexNumber(TString()));
- UNIT_ASSERT(IsHexNumber(u"0"));
- UNIT_ASSERT(IsHexNumber(u"aaaadddAAAAA"));
- UNIT_ASSERT(IsHexNumber(u"0123456789ABCDEFabcdef"));
- UNIT_ASSERT(IsHexNumber(u"12345678901234567890"));
- UNIT_ASSERT(IsHexNumber(u"1234567890a"));
- UNIT_ASSERT(!IsHexNumber(u"12345xx67890a"));
- UNIT_ASSERT(!IsHexNumber(u"foobar"));
+ UNIT_ASSERT(IsHexNumber(u"0"));
+ UNIT_ASSERT(IsHexNumber(u"aaaadddAAAAA"));
+ UNIT_ASSERT(IsHexNumber(u"0123456789ABCDEFabcdef"));
+ UNIT_ASSERT(IsHexNumber(u"12345678901234567890"));
+ UNIT_ASSERT(IsHexNumber(u"1234567890a"));
+ UNIT_ASSERT(!IsHexNumber(u"12345xx67890a"));
+ UNIT_ASSERT(!IsHexNumber(u"foobar"));
UNIT_ASSERT(!IsHexNumber(TUtf16String()));
}
}
diff --git a/util/string/vector_ut.cpp b/util/string/vector_ut.cpp
index 817120f268..2bedd38534 100644
--- a/util/string/vector_ut.cpp
+++ b/util/string/vector_ut.cpp
@@ -30,7 +30,7 @@ Y_UNIT_TEST_SUITE(TStringJoinTest) {
}
Y_UNIT_TEST(TestJoinWStrings) {
- const TUtf16String str = u"Яндекс";
+ const TUtf16String str = u"Яндекс";
const TVector<TUtf16String> v(1, str);
UNIT_ASSERT_EQUAL(JoinStrings(v, TUtf16String()), str);
diff --git a/util/system/types.h b/util/system/types.h
index 12e68a6060..37e9526216 100644
--- a/util/system/types.h
+++ b/util/system/types.h
@@ -101,13 +101,13 @@ typedef i64 SUPERLONG;
#endif
// UNICODE
-#ifdef __cplusplus
+#ifdef __cplusplus
// UCS-2, native byteorder
-typedef char16_t wchar16;
+typedef char16_t wchar16;
// internal symbol type: UTF-16LE
typedef wchar16 TChar;
-typedef char32_t wchar32;
-#endif
+typedef char32_t wchar32;
+#endif
#if defined(_MSC_VER)
#include <basetsd.h>