aboutsummaryrefslogtreecommitdiffstats
path: root/util/stream
diff options
context:
space:
mode:
authorStanislav Kirillov <staskirillov@gmail.com>2022-02-10 16:46:08 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:08 +0300
commitcb68f224c46a8ee52ac3fdd2a32534b8bb8dc134 (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /util/stream
parent92fe2b1e7bc79f7b95adef61714fc003f6ea4a1c (diff)
downloadydb-cb68f224c46a8ee52ac3fdd2a32534b8bb8dc134.tar.gz
Restoring authorship annotation for Stanislav Kirillov <staskirillov@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'util/stream')
-rw-r--r--util/stream/multi.cpp36
-rw-r--r--util/stream/multi_ut.cpp84
-rw-r--r--util/stream/ut/ya.make2
3 files changed, 61 insertions, 61 deletions
diff --git a/util/stream/multi.cpp b/util/stream/multi.cpp
index 1886032560..b2354298a0 100644
--- a/util/stream/multi.cpp
+++ b/util/stream/multi.cpp
@@ -23,25 +23,25 @@ size_t TMultiInput::DoRead(void* buf, size_t len) {
}
size_t TMultiInput::DoReadTo(TString& st, char ch) {
- size_t ret = C_->ReadTo(st, ch);
- if (ret == st.size() + 1) { // found a symbol, not eof
- return ret;
- }
-
- C_ = N_;
- N_ = &Cnull;
-
- if (ret == 0) {
- ret += C_->ReadTo(st, ch);
- } else {
+ size_t ret = C_->ReadTo(st, ch);
+ if (ret == st.size() + 1) { // found a symbol, not eof
+ return ret;
+ }
+
+ C_ = N_;
+ N_ = &Cnull;
+
+ if (ret == 0) {
+ ret += C_->ReadTo(st, ch);
+ } else {
TString tmp;
- ret += C_->ReadTo(tmp, ch);
- st += tmp;
- }
-
- return ret;
-}
-
+ ret += C_->ReadTo(tmp, ch);
+ st += tmp;
+ }
+
+ return ret;
+}
+
size_t TMultiInput::DoSkip(size_t len) {
const size_t ret = C_->Skip(len);
diff --git a/util/stream/multi_ut.cpp b/util/stream/multi_ut.cpp
index c9c328e5e3..fc2553b533 100644
--- a/util/stream/multi_ut.cpp
+++ b/util/stream/multi_ut.cpp
@@ -1,51 +1,51 @@
-#include "mem.h"
-#include "multi.h"
-#include "str.h"
+#include "mem.h"
+#include "multi.h"
+#include "str.h"
#include <library/cpp/testing/unittest/registar.h>
-
+
Y_UNIT_TEST_SUITE(TestMultiInput) {
- struct TTestCase {
- TMemoryInput Input1;
- TMemoryInput Input2;
- TMultiInput MultiInput;
+ struct TTestCase {
+ TMemoryInput Input1;
+ TMemoryInput Input2;
+ TMultiInput MultiInput;
TTestCase(const TStringBuf in1, const TStringBuf in2)
- : Input1(in1)
- , Input2(in2)
- , MultiInput(&Input1, &Input2)
- {
- }
- void TestReadToResult(char c, size_t expectedRetval,
+ : Input1(in1)
+ , Input2(in2)
+ , MultiInput(&Input1, &Input2)
+ {
+ }
+ void TestReadToResult(char c, size_t expectedRetval,
const TString& expectedValue,
const TString& initValue = "") {
TString t = initValue;
- UNIT_ASSERT_VALUES_EQUAL(MultiInput.ReadTo(t, c), expectedRetval);
- UNIT_ASSERT_VALUES_EQUAL(t, expectedValue);
- }
- };
-
+ UNIT_ASSERT_VALUES_EQUAL(MultiInput.ReadTo(t, c), expectedRetval);
+ UNIT_ASSERT_VALUES_EQUAL(t, expectedValue);
+ }
+ };
+
Y_UNIT_TEST(TestReadTo) {
TString t;
-
- TTestCase simpleCase("0123456789abc", "defghijk");
- simpleCase.TestReadToResult('7', 8, "0123456");
- simpleCase.TestReadToResult('f', 8, "89abcde");
- simpleCase.TestReadToResult('z', 5, "ghijk");
- }
-
+
+ TTestCase simpleCase("0123456789abc", "defghijk");
+ simpleCase.TestReadToResult('7', 8, "0123456");
+ simpleCase.TestReadToResult('f', 8, "89abcde");
+ simpleCase.TestReadToResult('z', 5, "ghijk");
+ }
+
Y_UNIT_TEST(TestReadToBetweenStreams) {
- TTestCase case1("0123456789abc", "defghijk");
- case1.TestReadToResult('c', 13, "0123456789ab");
- case1.TestReadToResult('k', 8, "defghij");
- case1.TestReadToResult('z', 0, "TRASH", "TRASH");
-
- TTestCase case2("0123456789abc", "defghijk");
- case2.TestReadToResult('d', 14, "0123456789abc");
- case2.TestReadToResult('j', 6, "efghi");
- case2.TestReadToResult('k', 1, "", "TRASH");
-
- TTestCase case3("0123456789abc", "defghijk");
- case3.TestReadToResult('e', 15, "0123456789abcd");
- case3.TestReadToResult('j', 5, "fghi");
- case3.TestReadToResult('k', 1, "", "TRASH");
- }
-}
+ TTestCase case1("0123456789abc", "defghijk");
+ case1.TestReadToResult('c', 13, "0123456789ab");
+ case1.TestReadToResult('k', 8, "defghij");
+ case1.TestReadToResult('z', 0, "TRASH", "TRASH");
+
+ TTestCase case2("0123456789abc", "defghijk");
+ case2.TestReadToResult('d', 14, "0123456789abc");
+ case2.TestReadToResult('j', 6, "efghi");
+ case2.TestReadToResult('k', 1, "", "TRASH");
+
+ TTestCase case3("0123456789abc", "defghijk");
+ case3.TestReadToResult('e', 15, "0123456789abcd");
+ case3.TestReadToResult('j', 5, "fghi");
+ case3.TestReadToResult('k', 1, "", "TRASH");
+ }
+}
diff --git a/util/stream/ut/ya.make b/util/stream/ut/ya.make
index 7b7d03ff01..f0176dd7b4 100644
--- a/util/stream/ut/ya.make
+++ b/util/stream/ut/ya.make
@@ -16,7 +16,7 @@ SRCS(
stream/labeled_ut.cpp
stream/length_ut.cpp
stream/mem_ut.cpp
- stream/multi_ut.cpp
+ stream/multi_ut.cpp
stream/printf_ut.cpp
stream/str_ut.cpp
stream/tokenizer_ut.cpp