diff options
author | Alexander Fokin <apfokin@gmail.com> | 2022-02-10 16:45:38 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:38 +0300 |
commit | bf9e69a933f89af083d895185f01ed65e4d90766 (patch) | |
tree | b2cc84ee7850122e7ccf51d0ea21e4fa7e7a5685 /util/stream/walk_ut.cpp | |
parent | 863a59a65247c24db7cb06789bc5cf79d04da32f (diff) | |
download | ydb-bf9e69a933f89af083d895185f01ed65e4d90766.tar.gz |
Restoring authorship annotation for Alexander Fokin <apfokin@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'util/stream/walk_ut.cpp')
-rw-r--r-- | util/stream/walk_ut.cpp | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/util/stream/walk_ut.cpp b/util/stream/walk_ut.cpp index 115e249607..e0a783799f 100644 --- a/util/stream/walk_ut.cpp +++ b/util/stream/walk_ut.cpp @@ -1,55 +1,55 @@ -#include "walk.h" - +#include "walk.h" + #include <library/cpp/testing/unittest/registar.h> - + class TStringListInput: public IWalkInput { -public: +public: TStringListInput(const TVector<TString>& data) : Data_(data) , Index_(0) { } - -protected: + +protected: size_t DoUnboundedNext(const void** ptr) override { - if (Index_ >= Data_.size()) { - return 0; - } - + if (Index_ >= Data_.size()) { + return 0; + } + const TString& string = Data_[Index_++]; - - *ptr = string.data(); - return string.size(); - } - -private: + + *ptr = string.data(); + return string.size(); + } + +private: const TVector<TString>& Data_; - size_t Index_; -}; - + size_t Index_; +}; + Y_UNIT_TEST_SUITE(TWalkTest) { Y_UNIT_TEST(ReadTo) { TVector<TString> data; - data.push_back("111a"); - data.push_back("222b"); - data.push_back("333c"); - data.push_back("444d"); - data.push_back("555e"); - data.push_back("666f"); - - TStringListInput input(data); - + data.push_back("111a"); + data.push_back("222b"); + data.push_back("333c"); + data.push_back("444d"); + data.push_back("555e"); + data.push_back("666f"); + + TStringListInput input(data); + TString tmp1 = input.ReadTo('c'); - UNIT_ASSERT_VALUES_EQUAL(tmp1, "111a222b333"); - - char tmp2; - input.Read(&tmp2, 1); - UNIT_ASSERT_VALUES_EQUAL(tmp2, '4'); - + UNIT_ASSERT_VALUES_EQUAL(tmp1, "111a222b333"); + + char tmp2; + input.Read(&tmp2, 1); + UNIT_ASSERT_VALUES_EQUAL(tmp2, '4'); + TString tmp3 = input.ReadTo('6'); - UNIT_ASSERT_VALUES_EQUAL(tmp3, "44d555e"); - + UNIT_ASSERT_VALUES_EQUAL(tmp3, "44d555e"); + TString tmp4 = input.ReadAll(); - UNIT_ASSERT_VALUES_EQUAL(tmp4, "66f"); - } -} + UNIT_ASSERT_VALUES_EQUAL(tmp4, "66f"); + } +} |