aboutsummaryrefslogtreecommitdiffstats
path: root/util/stream/buffered_ut.cpp
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:17 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:17 +0300
commitd3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch)
treedd4bd3ca0f36b817e96812825ffaf10d645803f2 /util/stream/buffered_ut.cpp
parent72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff)
downloadydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'util/stream/buffered_ut.cpp')
-rw-r--r--util/stream/buffered_ut.cpp116
1 files changed, 58 insertions, 58 deletions
diff --git a/util/stream/buffered_ut.cpp b/util/stream/buffered_ut.cpp
index bc5b9361a9..41d2fc3030 100644
--- a/util/stream/buffered_ut.cpp
+++ b/util/stream/buffered_ut.cpp
@@ -1,64 +1,64 @@
-#include "buffered.h"
-
+#include "buffered.h"
+
#include <library/cpp/testing/unittest/registar.h>
-
+
#include <util/generic/string.h>
-#include <util/random/mersenne.h>
-
+#include <util/random/mersenne.h>
+
Y_UNIT_TEST_SUITE(TestBufferedIO) {
- template <class TOut>
- inline void Run(TOut&& out) {
- TMersenne<ui64> r;
-
- for (size_t i = 0; i < 1000; ++i) {
- const size_t c = r.GenRand() % 10000;
+ template <class TOut>
+ inline void Run(TOut&& out) {
+ TMersenne<ui64> r;
+
+ for (size_t i = 0; i < 1000; ++i) {
+ const size_t c = r.GenRand() % 10000;
TString s;
-
- for (size_t j = 0; j < c; ++j) {
- s.append('A' + (r.GenRand() % 10));
- }
-
+
+ for (size_t j = 0; j < c; ++j) {
+ s.append('A' + (r.GenRand() % 10));
+ }
+
out.Write(s.data(), s.size());
- }
- }
-
+ }
+ }
+
Y_UNIT_TEST(TestEqual) {
TString s1;
TString s2;
-
- Run(TBuffered<TStringOutput>(8000, s1));
- Run(TAdaptivelyBuffered<TStringOutput>(s2));
-
- UNIT_ASSERT_VALUES_EQUAL(s1, s2);
- }
-
+
+ Run(TBuffered<TStringOutput>(8000, s1));
+ Run(TAdaptivelyBuffered<TStringOutput>(s2));
+
+ UNIT_ASSERT_VALUES_EQUAL(s1, s2);
+ }
+
Y_UNIT_TEST(Test1) {
TString s;
-
- TBuffered<TStringOutput>(100, s).Write("1", 1);
-
- UNIT_ASSERT_VALUES_EQUAL(s, "1");
- }
-
+
+ TBuffered<TStringOutput>(100, s).Write("1", 1);
+
+ UNIT_ASSERT_VALUES_EQUAL(s, "1");
+ }
+
Y_UNIT_TEST(Test2) {
TString s;
-
- TBuffered<TStringOutput>(1, s).Write("12", 2);
-
- UNIT_ASSERT_VALUES_EQUAL(s, "12");
- }
-
+
+ TBuffered<TStringOutput>(1, s).Write("12", 2);
+
+ UNIT_ASSERT_VALUES_EQUAL(s, "12");
+ }
+
Y_UNIT_TEST(Test3) {
TString s;
-
- auto&& b = TBuffered<TStringOutput>(1, s);
-
- b.Write("1", 1);
- b.Write("12", 2);
+
+ auto&& b = TBuffered<TStringOutput>(1, s);
+
+ b.Write("1", 1);
+ b.Write("12", 2);
b.Finish();
-
- UNIT_ASSERT_VALUES_EQUAL(s, "112");
- }
+
+ UNIT_ASSERT_VALUES_EQUAL(s, "112");
+ }
Y_UNIT_TEST(Test4) {
TString s;
@@ -74,7 +74,7 @@ Y_UNIT_TEST_SUITE(TestBufferedIO) {
}
template <class TOut>
- inline void DoGenAndWrite(TOut&& output, TString& str) {
+ inline void DoGenAndWrite(TOut&& output, TString& str) {
TMersenne<ui64> r;
for (size_t i = 0; i < 43210; ++i) {
str.append('A' + (r.GenRand() % 10));
@@ -111,21 +111,21 @@ Y_UNIT_TEST_SUITE(TestBufferedIO) {
TString s("0123456789abcdefghijklmn");
TBuffered<TStringInput> in(5, s);
char c;
- UNIT_ASSERT_VALUES_EQUAL(in.Read(&c, 1), 1); //1
+ UNIT_ASSERT_VALUES_EQUAL(in.Read(&c, 1), 1); //1
UNIT_ASSERT_VALUES_EQUAL(c, '0');
- UNIT_ASSERT_VALUES_EQUAL(in.Skip(4), 4); //5 end of buffer
- UNIT_ASSERT_VALUES_EQUAL(in.Read(&c, 1), 1); //6
+ UNIT_ASSERT_VALUES_EQUAL(in.Skip(4), 4); //5 end of buffer
+ UNIT_ASSERT_VALUES_EQUAL(in.Read(&c, 1), 1); //6
UNIT_ASSERT_VALUES_EQUAL(c, '5');
- UNIT_ASSERT_VALUES_EQUAL(in.Skip(3), 3); //9
- UNIT_ASSERT_VALUES_EQUAL(in.Read(&c, 1), 1); //10 end of buffer
+ UNIT_ASSERT_VALUES_EQUAL(in.Skip(3), 3); //9
+ UNIT_ASSERT_VALUES_EQUAL(in.Read(&c, 1), 1); //10 end of buffer
UNIT_ASSERT_VALUES_EQUAL(c, '9');
- UNIT_ASSERT_VALUES_EQUAL(in.Skip(3), 3); //13
- UNIT_ASSERT_VALUES_EQUAL(in.Read(&c, 1), 1); //14 start new buffer
+ UNIT_ASSERT_VALUES_EQUAL(in.Skip(3), 3); //13
+ UNIT_ASSERT_VALUES_EQUAL(in.Read(&c, 1), 1); //14 start new buffer
UNIT_ASSERT_VALUES_EQUAL(c, 'd');
- UNIT_ASSERT_VALUES_EQUAL(in.Skip(6), 6); //20
- UNIT_ASSERT_VALUES_EQUAL(in.Read(&c, 1), 1); //21 start new buffer
+ UNIT_ASSERT_VALUES_EQUAL(in.Skip(6), 6); //20
+ UNIT_ASSERT_VALUES_EQUAL(in.Read(&c, 1), 1); //21 start new buffer
UNIT_ASSERT_VALUES_EQUAL(c, 'k');
- UNIT_ASSERT_VALUES_EQUAL(in.Skip(6), 3); //24 eof
+ UNIT_ASSERT_VALUES_EQUAL(in.Skip(6), 3); //24 eof
}
Y_UNIT_TEST(TestReadTo) {
@@ -139,4 +139,4 @@ Y_UNIT_TEST_SUITE(TestBufferedIO) {
UNIT_ASSERT_VALUES_EQUAL(in.ReadTo(t, 'z'), 4);
UNIT_ASSERT_VALUES_EQUAL(t, "9abc");
}
-}
+}