aboutsummaryrefslogtreecommitdiffstats
path: root/util/stream
diff options
context:
space:
mode:
authorIlnur Khuziev <ilnur.khuziev@yandex.ru>2022-02-10 16:46:13 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:13 +0300
commit736dcd8ca259457a136f2f9f9168c44643914323 (patch)
treeddd46a036d68bfa83aa11b892f31243ea6b068a1 /util/stream
parent9bf2fa2b060c9881d3135c2208c624a1dd546ecc (diff)
downloadydb-736dcd8ca259457a136f2f9f9168c44643914323.tar.gz
Restoring authorship annotation for Ilnur Khuziev <ilnur.khuziev@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'util/stream')
-rw-r--r--util/stream/aligned_ut.cpp2
-rw-r--r--util/stream/buffer_ut.cpp2
-rw-r--r--util/stream/buffered_ut.cpp2
-rw-r--r--util/stream/direct_io_ut.cpp2
-rw-r--r--util/stream/file_ut.cpp2
-rw-r--r--util/stream/format.cpp144
-rw-r--r--util/stream/format.h82
-rw-r--r--util/stream/format_ut.cpp74
-rw-r--r--util/stream/hex_ut.cpp2
-rw-r--r--util/stream/input_ut.cpp2
-rw-r--r--util/stream/ios_ut.cpp2
-rw-r--r--util/stream/labeled_ut.cpp2
-rw-r--r--util/stream/length_ut.cpp2
-rw-r--r--util/stream/mem_ut.cpp2
-rw-r--r--util/stream/multi_ut.cpp2
-rw-r--r--util/stream/output.cpp54
-rw-r--r--util/stream/output.h28
-rw-r--r--util/stream/printf_ut.cpp2
-rw-r--r--util/stream/str.h2
-rw-r--r--util/stream/str_ut.cpp28
-rw-r--r--util/stream/tokenizer_ut.cpp2
-rw-r--r--util/stream/walk_ut.cpp2
-rw-r--r--util/stream/zerocopy_output_ut.cpp2
-rw-r--r--util/stream/zlib_ut.cpp2
24 files changed, 223 insertions, 223 deletions
diff --git a/util/stream/aligned_ut.cpp b/util/stream/aligned_ut.cpp
index e980d05cf7..4f0e19d07b 100644
--- a/util/stream/aligned_ut.cpp
+++ b/util/stream/aligned_ut.cpp
@@ -1,6 +1,6 @@
#include "aligned.h"
-#include <library/cpp/testing/unittest/registar.h>
+#include <library/cpp/testing/unittest/registar.h>
class TNastyInputStream: public IInputStream {
public:
diff --git a/util/stream/buffer_ut.cpp b/util/stream/buffer_ut.cpp
index 3494696190..22c05e77e1 100644
--- a/util/stream/buffer_ut.cpp
+++ b/util/stream/buffer_ut.cpp
@@ -1,6 +1,6 @@
#include "buffer.h"
-#include <library/cpp/testing/unittest/registar.h>
+#include <library/cpp/testing/unittest/registar.h>
#include <util/generic/buffer.h>
diff --git a/util/stream/buffered_ut.cpp b/util/stream/buffered_ut.cpp
index 41d2fc3030..d091a23648 100644
--- a/util/stream/buffered_ut.cpp
+++ b/util/stream/buffered_ut.cpp
@@ -1,6 +1,6 @@
#include "buffered.h"
-#include <library/cpp/testing/unittest/registar.h>
+#include <library/cpp/testing/unittest/registar.h>
#include <util/generic/string.h>
#include <util/random/mersenne.h>
diff --git a/util/stream/direct_io_ut.cpp b/util/stream/direct_io_ut.cpp
index 01d09db232..6c23d6c5f3 100644
--- a/util/stream/direct_io_ut.cpp
+++ b/util/stream/direct_io_ut.cpp
@@ -1,4 +1,4 @@
-#include <library/cpp/testing/unittest/registar.h>
+#include <library/cpp/testing/unittest/registar.h>
#include <util/generic/string.h>
#include <util/generic/array_size.h>
diff --git a/util/stream/file_ut.cpp b/util/stream/file_ut.cpp
index ac0f09796e..84de4e9a05 100644
--- a/util/stream/file_ut.cpp
+++ b/util/stream/file_ut.cpp
@@ -1,6 +1,6 @@
#include "file.h"
-#include <library/cpp/testing/unittest/registar.h>
+#include <library/cpp/testing/unittest/registar.h>
#include <util/system/tempfile.h>
diff --git a/util/stream/format.cpp b/util/stream/format.cpp
index 3996130df5..eafdd20f81 100644
--- a/util/stream/format.cpp
+++ b/util/stream/format.cpp
@@ -4,13 +4,13 @@
#include <util/generic/ymath.h>
#include <util/string/cast.h>
-namespace NFormatPrivate {
- static inline i64 Round(double value) {
- double res1 = floor(value);
- double res2 = ceil(value);
+namespace NFormatPrivate {
+ static inline i64 Round(double value) {
+ double res1 = floor(value);
+ double res2 = ceil(value);
return (value - res1 < res2 - value) ? (i64)res1 : (i64)res2;
- }
-
+ }
+
static inline IOutputStream& PrintDoubleShortly(IOutputStream& os, const double& d) {
// General case: request 3 significant digits
// Side-effect: allows exponential representation
@@ -33,95 +33,95 @@ namespace NFormatPrivate {
}
return os << Prec(d, mode, ndigits);
- }
+ }
}
-
+
template <>
void Out<NFormatPrivate::THumanReadableSize>(IOutputStream& stream, const NFormatPrivate::THumanReadableSize& value) {
ui64 base = value.Format == SF_BYTES ? 1024 : 1000;
ui64 base2 = base * base;
ui64 base3 = base * base2;
ui64 base4 = base * base3;
-
- double v = value.Value;
- if (v < 0) {
- stream << "-";
- v = -v;
- }
-
- if (v < base) {
- NFormatPrivate::PrintDoubleShortly(stream, v);
+
+ double v = value.Value;
+ if (v < 0) {
+ stream << "-";
+ v = -v;
+ }
+
+ if (v < base) {
+ NFormatPrivate::PrintDoubleShortly(stream, v);
} else if (v < base2) {
- NFormatPrivate::PrintDoubleShortly(stream, v / (double)base) << 'K';
+ NFormatPrivate::PrintDoubleShortly(stream, v / (double)base) << 'K';
} else if (v < base3) {
- NFormatPrivate::PrintDoubleShortly(stream, v / (double)base2) << 'M';
+ NFormatPrivate::PrintDoubleShortly(stream, v / (double)base2) << 'M';
} else if (v < base4) {
- NFormatPrivate::PrintDoubleShortly(stream, v / (double)base3) << 'G';
- } else {
- NFormatPrivate::PrintDoubleShortly(stream, v / (double)base4) << 'T';
- }
-
+ NFormatPrivate::PrintDoubleShortly(stream, v / (double)base3) << 'G';
+ } else {
+ NFormatPrivate::PrintDoubleShortly(stream, v / (double)base4) << 'T';
+ }
+
if (value.Format == SF_BYTES) {
- if (v < base) {
+ if (v < base) {
stream << "B";
} else {
stream << "iB";
}
}
-}
-
+}
+
template <>
void Out<NFormatPrivate::THumanReadableDuration>(IOutputStream& os, const NFormatPrivate::THumanReadableDuration& hr) {
- TTempBuf buf;
- TMemoryOutput ss(buf.Data(), buf.Size());
-
- do {
- ui64 microSeconds = hr.Value.MicroSeconds();
- if (microSeconds < 1000) {
- ss << microSeconds << "us";
- break;
- }
- if (microSeconds < 1000 * 1000) {
+ TTempBuf buf;
+ TMemoryOutput ss(buf.Data(), buf.Size());
+
+ do {
+ ui64 microSeconds = hr.Value.MicroSeconds();
+ if (microSeconds < 1000) {
+ ss << microSeconds << "us";
+ break;
+ }
+ if (microSeconds < 1000 * 1000) {
NFormatPrivate::PrintDoubleShortly(ss, (double)microSeconds / 1000.0) << "ms";
- break;
- }
-
+ break;
+ }
+
double seconds = (double)(hr.Value.MilliSeconds()) / 1000.0;
- if (seconds < 60) {
- NFormatPrivate::PrintDoubleShortly(ss, seconds) << 's';
- break;
- }
-
- ui64 s = NFormatPrivate::Round(seconds * 1000 + 0.5) / 1000;
-
- ui64 m = s / 60;
- s = s % 60;
-
- ui64 h = m / 60;
- m = m % 60;
-
- ui64 d = h / 24;
- h = h % 24;
-
- ui64 times[] = {d, h, m, s};
- char names[] = {'d', 'h', 'm', 's'};
- bool first = true;
-
+ if (seconds < 60) {
+ NFormatPrivate::PrintDoubleShortly(ss, seconds) << 's';
+ break;
+ }
+
+ ui64 s = NFormatPrivate::Round(seconds * 1000 + 0.5) / 1000;
+
+ ui64 m = s / 60;
+ s = s % 60;
+
+ ui64 h = m / 60;
+ m = m % 60;
+
+ ui64 d = h / 24;
+ h = h % 24;
+
+ ui64 times[] = {d, h, m, s};
+ char names[] = {'d', 'h', 'm', 's'};
+ bool first = true;
+
for (size_t i = 0; i < Y_ARRAY_SIZE(times); ++i) {
- if (times[i] > 0) {
+ if (times[i] > 0) {
if (!first) {
- ss << ' ';
+ ss << ' ';
}
- ss << times[i] << names[i];
- first = false;
- }
- }
- } while (false);
-
- size_t written = buf.Size() - ss.Avail();
- os.Write(buf.Data(), written);
-}
-
+ ss << times[i] << names[i];
+ first = false;
+ }
+ }
+ } while (false);
+
+ size_t written = buf.Size() - ss.Avail();
+ os.Write(buf.Data(), written);
+}
+
void Time(IOutputStream& l) {
l << millisec();
}
diff --git a/util/stream/format.h b/util/stream/format.h
index b033208a1b..031559a424 100644
--- a/util/stream/format.h
+++ b/util/stream/format.h
@@ -3,10 +3,10 @@
#include "mem.h"
#include "output.h"
-#include <util/datetime/base.h>
-#include <util/generic/strbuf.h>
+#include <util/datetime/base.h>
+#include <util/generic/strbuf.h>
#include <util/generic/flags.h>
-#include <util/memory/tempbuf.h>
+#include <util/memory/tempbuf.h>
#include <util/string/cast.h>
enum ENumberFormatFlag {
@@ -131,27 +131,27 @@ namespace NFormatPrivate {
stream << str;
return stream;
}
-
+
template <typename Char, size_t Base>
struct TBaseText {
TBasicStringBuf<Char> Text;
-
+
inline TBaseText(const TBasicStringBuf<Char> text)
- : Text(text)
+ : Text(text)
{
}
- };
-
+ };
+
template <typename Char, size_t Base>
IOutputStream& operator<<(IOutputStream& os, const TBaseText<Char, Base>& text) {
for (size_t i = 0; i < text.Text.size(); ++i) {
- if (i != 0) {
- os << ' ';
- }
+ if (i != 0) {
+ os << ' ';
+ }
os << TUnsignedBaseNumber<Char, Base>(text.Text[i], HF_FULL);
- }
- return os;
- }
+ }
+ return os;
+ }
template <typename T>
struct TFloatPrecision {
@@ -170,20 +170,20 @@ namespace NFormatPrivate {
o << TStringBuf(buf, count);
return o;
}
-
- struct THumanReadableDuration {
- TDuration Value;
-
+
+ struct THumanReadableDuration {
+ TDuration Value;
+
constexpr THumanReadableDuration(const TDuration& value)
- : Value(value)
+ : Value(value)
{
}
- };
-
- struct THumanReadableSize {
- double Value;
+ };
+
+ struct THumanReadableSize {
+ double Value;
ESizeFormat Format;
- };
+ };
}
/**
@@ -280,7 +280,7 @@ static constexpr ::NFormatPrivate::TBaseNumber<T, 16> SHex(const T& value, const
return {value, flags};
}
-/**
+/**
* Output manipulator similar to `std::setbase(2)`.
*
* When written into a `IOutputStream`, writes out the provided value in
@@ -335,12 +335,12 @@ static constexpr ::NFormatPrivate::TBaseNumber<T, 2> SBin(const T& value, const
*
* @param value String to output.
*/
-template <typename TChar>
+template <typename TChar>
static inline ::NFormatPrivate::TBaseText<TChar, 16> HexText(const TBasicStringBuf<TChar> value) {
return ::NFormatPrivate::TBaseText<TChar, 16>(value);
-}
-
-/**
+}
+
+/**
* Output manipulator for binary string output.
*
* When written into a `IOutputStream`, writes out the provided characters
@@ -373,10 +373,10 @@ static inline ::NFormatPrivate::TBaseText<TChar, 2> BinText(const TBasicStringBu
* @param value Value to output.
*/
static constexpr ::NFormatPrivate::THumanReadableDuration HumanReadable(const TDuration duration) noexcept {
- return ::NFormatPrivate::THumanReadableDuration(duration);
-}
-
-/**
+ return ::NFormatPrivate::THumanReadableDuration(duration);
+}
+
+/**
* Output manipulator for writing out human-readable number of elements / memory
* amount in `ls -h` style.
*
@@ -388,22 +388,22 @@ static constexpr ::NFormatPrivate::THumanReadableDuration HumanReadable(const TD
*
* Example usage:
* @code
- * stream << HumanReadableSize(1024, SF_QUANTITY); // Will output "1.02K"
- * stream << HumanReadableSize(1024, SF_BYTES); // Will output "1KiB"
- * stream << "average usage " << HumanReadableSize(100 / 3., SF_BYTES); // Will output "average usage "33.3B""
+ * stream << HumanReadableSize(1024, SF_QUANTITY); // Will output "1.02K"
+ * stream << HumanReadableSize(1024, SF_BYTES); // Will output "1KiB"
+ * stream << "average usage " << HumanReadableSize(100 / 3., SF_BYTES); // Will output "average usage "33.3B""
* @endcode
*
* @param value Value to output.
* @param format Format to use.
*/
-static constexpr ::NFormatPrivate::THumanReadableSize HumanReadableSize(const double size, ESizeFormat format) noexcept {
+static constexpr ::NFormatPrivate::THumanReadableSize HumanReadableSize(const double size, ESizeFormat format) noexcept {
return {size, format};
-}
-
+}
+
void Time(IOutputStream& l);
void TimeHumanReadable(IOutputStream& l);
-/**
+/**
* Output manipulator for adjusting precision of floating point values.
*
* When written into a `IOutputStream`, writes out the provided floating point
@@ -424,7 +424,7 @@ static constexpr ::NFormatPrivate::TFloatPrecision<T> Prec(const T& value, const
return {value, mode, ndigits};
}
-/**
+/**
* Output manipulator for adjusting precision of floating point values.
*
* When written into a `IOutputStream`, writes out the provided floating point
diff --git a/util/stream/format_ut.cpp b/util/stream/format_ut.cpp
index 43245aeb48..b650a4f57f 100644
--- a/util/stream/format_ut.cpp
+++ b/util/stream/format_ut.cpp
@@ -1,7 +1,7 @@
#include "format.h"
-#include <library/cpp/testing/unittest/registar.h>
-#include <util/charset/wide.h>
+#include <library/cpp/testing/unittest/registar.h>
+#include <util/charset/wide.h>
Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) {
Y_UNIT_TEST(TestLeftPad) {
@@ -45,20 +45,20 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) {
(*ss) << Hex(*ii);
UNIT_ASSERT_VALUES_EQUAL("0x01234567", ss->Str());
}
-
+
Y_UNIT_TEST(TestHexText) {
- {
- TStringStream ss;
+ {
+ TStringStream ss;
ss << HexText(TStringBuf("abcи"));
- UNIT_ASSERT_VALUES_EQUAL("61 62 63 D0 B8", ss.Str());
- }
- {
- TStringStream ss;
+ UNIT_ASSERT_VALUES_EQUAL("61 62 63 D0 B8", ss.Str());
+ }
+ {
+ TStringStream ss;
TUtf16String w = UTF8ToWide("abcи");
- ss << HexText<wchar16>(w);
- UNIT_ASSERT_VALUES_EQUAL("0061 0062 0063 0438", ss.Str());
- }
- }
+ ss << HexText<wchar16>(w);
+ UNIT_ASSERT_VALUES_EQUAL("0061 0062 0063 0438", ss.Str());
+ }
+ }
Y_UNIT_TEST(TestBin) {
UNIT_ASSERT_VALUES_EQUAL(ToString(Bin(static_cast<ui32>(2), nullptr)), "10");
@@ -94,7 +94,7 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) {
ss << Prec(1.2345678901234567, PREC_POINT_DIGITS, 3);
UNIT_ASSERT_VALUES_EQUAL("1.235", ss.Str());
}
-
+
Y_UNIT_TEST(TestHumanReadableSize1000) {
UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(0, SF_QUANTITY)), "0");
@@ -109,8 +109,8 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) {
UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(-1234567, SF_QUANTITY)), "-1.23M");
UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(-12345678, SF_QUANTITY)), "-12.3M");
UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(-12345678 * 1000ll, SF_QUANTITY)), "-12.3G");
- }
-
+ }
+
Y_UNIT_TEST(TestHumanReadableSize1024) {
UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(0, SF_BYTES)), "0B");
@@ -123,7 +123,7 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) {
UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(5 * 1024 * 1024, SF_BYTES)), "5MiB");
UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(1236 * 1024 * 1024, SF_BYTES)), "1.21GiB");
UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(1024ull * 1024 * 1024 * 1024, SF_BYTES)), "1TiB");
- UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(100 / 3., SF_BYTES)), "33.3B");
+ UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(100 / 3., SF_BYTES)), "33.3B");
UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(-100, SF_BYTES)), "-100B");
UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(-1024, SF_BYTES)), "-1KiB");
@@ -134,7 +134,7 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) {
UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(-5 * 1024 * 1024, SF_BYTES)), "-5MiB");
UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(-1236 * 1024 * 1024, SF_BYTES)), "-1.21GiB");
UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(-1024ll * 1024 * 1024 * 1024, SF_BYTES)), "-1TiB");
- UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(-100 / 3., SF_BYTES)), "-33.3B");
+ UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(-100 / 3., SF_BYTES)), "-33.3B");
// XXX: For 1000 <= x < 1024, Prec(x, 3) falls back to exponential form
@@ -159,24 +159,24 @@ Y_UNIT_TEST_SUITE(TOutputStreamFormattingTest) {
UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(-1010ll * 1024 * 1024 * 1024, SF_BYTES)), "-1010GiB");
UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(-1000ll * 1024 * 1024 * 1024 * 1024, SF_BYTES)), "-1000TiB");
UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadableSize(-1010ll * 1024 * 1024 * 1024 * 1024, SF_BYTES)), "-1010TiB");
- }
-
+ }
+
Y_UNIT_TEST(TestHumanReadableDuration) {
- UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::MicroSeconds(0))), "0us");
- UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::MicroSeconds(1))), "1us");
- UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::MicroSeconds(100))), "100us");
- UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::MicroSeconds(1234))), "1.23ms");
- UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::MicroSeconds(12345))), "12.3ms");
- UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::MicroSeconds(1234567))), "1.23s");
- UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::Seconds(5))), "5s");
- UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::Seconds(59.9))), "59.9s");
-
- UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::Seconds(60))), "1m");
- UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::Seconds(61))), "1m 1s");
- UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::Seconds(72))), "1m 12s");
- UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::Seconds(620))), "10m 20s");
- UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::Seconds(3600))), "1h");
- UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::Seconds(3672))), "1h 1m 12s");
- UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::Seconds(4220))), "1h 10m 20s");
- }
+ UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::MicroSeconds(0))), "0us");
+ UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::MicroSeconds(1))), "1us");
+ UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::MicroSeconds(100))), "100us");
+ UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::MicroSeconds(1234))), "1.23ms");
+ UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::MicroSeconds(12345))), "12.3ms");
+ UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::MicroSeconds(1234567))), "1.23s");
+ UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::Seconds(5))), "5s");
+ UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::Seconds(59.9))), "59.9s");
+
+ UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::Seconds(60))), "1m");
+ UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::Seconds(61))), "1m 1s");
+ UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::Seconds(72))), "1m 12s");
+ UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::Seconds(620))), "10m 20s");
+ UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::Seconds(3600))), "1h");
+ UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::Seconds(3672))), "1h 1m 12s");
+ UNIT_ASSERT_VALUES_EQUAL(ToString(HumanReadable(TDuration::Seconds(4220))), "1h 10m 20s");
+ }
}
diff --git a/util/stream/hex_ut.cpp b/util/stream/hex_ut.cpp
index 5074a0b616..f4c29a2c90 100644
--- a/util/stream/hex_ut.cpp
+++ b/util/stream/hex_ut.cpp
@@ -1,6 +1,6 @@
#include "hex.h"
-#include <library/cpp/testing/unittest/registar.h>
+#include <library/cpp/testing/unittest/registar.h>
#include "str.h"
Y_UNIT_TEST_SUITE(THexCodingTest) {
diff --git a/util/stream/input_ut.cpp b/util/stream/input_ut.cpp
index 4a93f5458e..fd45827407 100644
--- a/util/stream/input_ut.cpp
+++ b/util/stream/input_ut.cpp
@@ -1,7 +1,7 @@
#include "input.h"
#include "output.h"
-#include <library/cpp/testing/unittest/registar.h>
+#include <library/cpp/testing/unittest/registar.h>
#include <util/system/file.h>
#include <util/system/yassert.h>
diff --git a/util/stream/ios_ut.cpp b/util/stream/ios_ut.cpp
index 139f4296e5..51ab9a5735 100644
--- a/util/stream/ios_ut.cpp
+++ b/util/stream/ios_ut.cpp
@@ -4,7 +4,7 @@
#include "buffered.h"
#include "walk.h"
-#include <library/cpp/testing/unittest/registar.h>
+#include <library/cpp/testing/unittest/registar.h>
#include <util/string/cast.h>
#include <util/memory/tempbuf.h>
diff --git a/util/stream/labeled_ut.cpp b/util/stream/labeled_ut.cpp
index 12d0dc5004..da3b99fdba 100644
--- a/util/stream/labeled_ut.cpp
+++ b/util/stream/labeled_ut.cpp
@@ -1,6 +1,6 @@
#include "str.h"
-#include <library/cpp/testing/unittest/registar.h>
+#include <library/cpp/testing/unittest/registar.h>
Y_UNIT_TEST_SUITE(TLabeledOutputTest) {
Y_UNIT_TEST(TBasicTest) {
diff --git a/util/stream/length_ut.cpp b/util/stream/length_ut.cpp
index 8968448954..5a21ca1630 100644
--- a/util/stream/length_ut.cpp
+++ b/util/stream/length_ut.cpp
@@ -1,6 +1,6 @@
#include "length.h"
-#include <library/cpp/testing/unittest/registar.h>
+#include <library/cpp/testing/unittest/registar.h>
#include <util/generic/string.h>
diff --git a/util/stream/mem_ut.cpp b/util/stream/mem_ut.cpp
index f388ae66ac..5042ee55f5 100644
--- a/util/stream/mem_ut.cpp
+++ b/util/stream/mem_ut.cpp
@@ -1,6 +1,6 @@
#include "mem.h"
-#include <library/cpp/testing/unittest/registar.h>
+#include <library/cpp/testing/unittest/registar.h>
Y_UNIT_TEST_SUITE(TestMemIO) {
Y_UNIT_TEST(TestReadTo) {
diff --git a/util/stream/multi_ut.cpp b/util/stream/multi_ut.cpp
index fc2553b533..ef67d30861 100644
--- a/util/stream/multi_ut.cpp
+++ b/util/stream/multi_ut.cpp
@@ -1,7 +1,7 @@
#include "mem.h"
#include "multi.h"
#include "str.h"
-#include <library/cpp/testing/unittest/registar.h>
+#include <library/cpp/testing/unittest/registar.h>
Y_UNIT_TEST_SUITE(TestMultiInput) {
struct TTestCase {
diff --git a/util/stream/output.cpp b/util/stream/output.cpp
index db81b81b70..8faaca2b32 100644
--- a/util/stream/output.cpp
+++ b/util/stream/output.cpp
@@ -79,16 +79,16 @@ static void WriteString(IOutputStream& o, const wchar16* w, size_t n) {
o.Write(data, written);
}
-static void WriteString(IOutputStream& o, const wchar32* 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
- TTempBuf buffer(buflen + 1);
- char* const data = buffer.Data();
- size_t written = 0;
- WideToUTF8(w, n, data, written);
- data[written] = 0;
- o.Write(data, written);
-}
-
+ TTempBuf buffer(buflen + 1);
+ char* const data = buffer.Data();
+ size_t written = 0;
+ WideToUTF8(w, n, data, written);
+ data[written] = 0;
+ o.Write(data, written);
+}
+
template <>
void Out<TString>(IOutputStream& o, const TString& p) {
o.Write(p.data(), p.size());
@@ -139,24 +139,24 @@ void Out<const wchar16*>(IOutputStream& o, const wchar16* w) {
}
template <>
-void Out<const wchar32*>(IOutputStream& o, const wchar32* w) {
- if (w) {
+void Out<const wchar32*>(IOutputStream& o, const wchar32* w) {
+ if (w) {
WriteString(o, w, std::char_traits<wchar32>::length(w));
- } else {
- o.Write("(null)");
- }
-}
-
-template <>
+ } else {
+ o.Write("(null)");
+ }
+}
+
+template <>
void Out<TUtf16String>(IOutputStream& o, const TUtf16String& w) {
WriteString(o, w.c_str(), w.size());
}
-template <>
-void Out<TUtf32String>(IOutputStream& o, const TUtf32String& w) {
- WriteString(o, w.c_str(), w.size());
-}
-
+template <>
+void Out<TUtf32String>(IOutputStream& o, const TUtf32String& w) {
+ WriteString(o, w.c_str(), w.size());
+}
+
#define DEF_CONV_DEFAULT(type) \
template <> \
void Out<type>(IOutputStream & o, type p) { \
@@ -221,12 +221,12 @@ void Out<TBasicCharRef<TUtf16String>>(IOutputStream& o, const TBasicCharRef<TUtf
}
template <>
-void Out<TBasicCharRef<TUtf32String>>(IOutputStream& o, const TBasicCharRef<TUtf32String>& c) {
- o << static_cast<wchar32>(c);
-}
+void Out<TBasicCharRef<TUtf32String>>(IOutputStream& o, const TBasicCharRef<TUtf32String>& c) {
+ o << static_cast<wchar32>(c);
+}
#endif
-
-template <>
+
+template <>
void Out<const void*>(IOutputStream& o, const void* t) {
o << Hex(size_t(t));
}
diff --git a/util/stream/output.h b/util/stream/output.h
index 00eef50b95..a5d992206d 100644
--- a/util/stream/output.h
+++ b/util/stream/output.h
@@ -45,7 +45,7 @@ public:
inline ~TPart() = default;
static inline TPart CrLf() noexcept {
- return TPart("\r\n", 2);
+ return TPart("\r\n", 2);
}
const void* buf;
@@ -204,9 +204,9 @@ inline void Out<const char*>(IOutputStream& o, const char* t) {
template <>
void Out<const wchar16*>(IOutputStream& o, const wchar16* w);
-template <>
-void Out<const wchar32*>(IOutputStream& o, const wchar32* w);
-
+template <>
+void Out<const wchar32*>(IOutputStream& o, const wchar32* w);
+
static inline IOutputStream& operator<<(IOutputStream& o, TStreamManipulator m) {
m(o);
@@ -249,16 +249,16 @@ static inline IOutputStream& operator<<(IOutputStream& o, wchar16* t) {
return o;
}
-static inline IOutputStream& operator<<(IOutputStream& o, const wchar32* t) {
- Out<const wchar32*>(o, t);
- return o;
-}
-
-static inline IOutputStream& operator<<(IOutputStream& o, wchar32* t) {
- Out<const wchar32*>(o, t);
- return o;
-}
-
+static inline IOutputStream& operator<<(IOutputStream& o, const wchar32* t) {
+ Out<const wchar32*>(o, t);
+ return o;
+}
+
+static inline IOutputStream& operator<<(IOutputStream& o, wchar32* t) {
+ Out<const wchar32*>(o, t);
+ return o;
+}
+
namespace NPrivate {
IOutputStream& StdOutStream() noexcept;
IOutputStream& StdErrStream() noexcept;
diff --git a/util/stream/printf_ut.cpp b/util/stream/printf_ut.cpp
index 0eab167062..a364194a76 100644
--- a/util/stream/printf_ut.cpp
+++ b/util/stream/printf_ut.cpp
@@ -4,7 +4,7 @@
#include <util/generic/string.h>
-#include <library/cpp/testing/unittest/registar.h>
+#include <library/cpp/testing/unittest/registar.h>
Y_UNIT_TEST_SUITE(TStreamPrintfTest) {
Y_UNIT_TEST(TestPrintf) {
diff --git a/util/stream/str.h b/util/stream/str.h
index 028bd572c0..03c7003820 100644
--- a/util/stream/str.h
+++ b/util/stream/str.h
@@ -79,7 +79,7 @@ public:
}
TStringOutput(TStringOutput&& s) noexcept = default;
-
+
~TStringOutput() override;
/**
diff --git a/util/stream/str_ut.cpp b/util/stream/str_ut.cpp
index fc6b46c31a..ca770770b9 100644
--- a/util/stream/str_ut.cpp
+++ b/util/stream/str_ut.cpp
@@ -1,6 +1,6 @@
#include "str.h"
-#include <library/cpp/testing/unittest/registar.h>
+#include <library/cpp/testing/unittest/registar.h>
#include <util/generic/typetraits.h>
template <typename T>
@@ -136,17 +136,17 @@ Y_UNIT_TEST_SUITE(TStringInputOutputTest) {
UNIT_ASSERT_STRINGS_EQUAL(str, "1234567890");
}
-
- Y_UNIT_TEST(MoveConstructor) {
- TString str;
- TStringOutput output1(str);
- output1 << "foo";
-
- TStringOutput output2 = std::move(output1);
- output2 << "bar";
- UNIT_ASSERT_STRINGS_EQUAL(str, "foobar");
-
- // Check old stream is in a valid state
- output1 << "baz";
- }
+
+ Y_UNIT_TEST(MoveConstructor) {
+ TString str;
+ TStringOutput output1(str);
+ output1 << "foo";
+
+ TStringOutput output2 = std::move(output1);
+ output2 << "bar";
+ UNIT_ASSERT_STRINGS_EQUAL(str, "foobar");
+
+ // Check old stream is in a valid state
+ output1 << "baz";
+ }
}
diff --git a/util/stream/tokenizer_ut.cpp b/util/stream/tokenizer_ut.cpp
index afc566da86..1d0de89b12 100644
--- a/util/stream/tokenizer_ut.cpp
+++ b/util/stream/tokenizer_ut.cpp
@@ -1,4 +1,4 @@
-#include <library/cpp/testing/unittest/registar.h>
+#include <library/cpp/testing/unittest/registar.h>
#include <util/generic/array_size.h>
#include <util/generic/strbuf.h>
diff --git a/util/stream/walk_ut.cpp b/util/stream/walk_ut.cpp
index e0a783799f..30a0c7c59e 100644
--- a/util/stream/walk_ut.cpp
+++ b/util/stream/walk_ut.cpp
@@ -1,6 +1,6 @@
#include "walk.h"
-#include <library/cpp/testing/unittest/registar.h>
+#include <library/cpp/testing/unittest/registar.h>
class TStringListInput: public IWalkInput {
public:
diff --git a/util/stream/zerocopy_output_ut.cpp b/util/stream/zerocopy_output_ut.cpp
index e81f7fb056..81474adf84 100644
--- a/util/stream/zerocopy_output_ut.cpp
+++ b/util/stream/zerocopy_output_ut.cpp
@@ -1,6 +1,6 @@
#include "zerocopy_output.h"
-#include <library/cpp/testing/unittest/registar.h>
+#include <library/cpp/testing/unittest/registar.h>
#include <util/generic/string.h>
diff --git a/util/stream/zlib_ut.cpp b/util/stream/zlib_ut.cpp
index 2290b4a9de..e093b9df79 100644
--- a/util/stream/zlib_ut.cpp
+++ b/util/stream/zlib_ut.cpp
@@ -1,6 +1,6 @@
#include "zlib.h"
-#include <library/cpp/testing/unittest/registar.h>
+#include <library/cpp/testing/unittest/registar.h>
#include "file.h"
#include <util/system/tempfile.h>