diff options
author | hippskill <hippskill@yandex-team.ru> | 2022-02-10 16:50:12 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:12 +0300 |
commit | bd077d09a08e659195376ee97dc24728bb554246 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /util/generic/iterator_ut.cpp | |
parent | 6362c4a2681cc317ffd22633d773f02de0d13697 (diff) | |
download | ydb-bd077d09a08e659195376ee97dc24728bb554246.tar.gz |
Restoring authorship annotation for <hippskill@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/generic/iterator_ut.cpp')
-rw-r--r-- | util/generic/iterator_ut.cpp | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/util/generic/iterator_ut.cpp b/util/generic/iterator_ut.cpp index 5dc085c821..00be19e10e 100644 --- a/util/generic/iterator_ut.cpp +++ b/util/generic/iterator_ut.cpp @@ -9,55 +9,55 @@ Y_UNIT_TEST_SUITE(TIterator) { UNIT_ASSERT_VALUES_EQUAL(*ToForwardIterator(std::prev(x.rend())), *x.begin()); } } - -Y_UNIT_TEST_SUITE(TInputRangeAdaptor) { + +Y_UNIT_TEST_SUITE(TInputRangeAdaptor) { class TSquaresGenerator: public TInputRangeAdaptor<TSquaresGenerator> { - public: - const i64* Next() { - Current_ = State_ * State_; - ++State_; - // Never return nullptr => we have infinite range! - return &Current_; - } - - private: - i64 State_ = 0.0; - i64 Current_ = 0.0; - }; - - Y_UNIT_TEST(TSquaresGenerator) { - i64 cur = 0; - for (i64 sqr : TSquaresGenerator{}) { - UNIT_ASSERT_VALUES_EQUAL(cur * cur, sqr); - - if (++cur > 10) { - break; - } - } - } - + public: + const i64* Next() { + Current_ = State_ * State_; + ++State_; + // Never return nullptr => we have infinite range! + return &Current_; + } + + private: + i64 State_ = 0.0; + i64 Current_ = 0.0; + }; + + Y_UNIT_TEST(TSquaresGenerator) { + i64 cur = 0; + for (i64 sqr : TSquaresGenerator{}) { + UNIT_ASSERT_VALUES_EQUAL(cur * cur, sqr); + + if (++cur > 10) { + break; + } + } + } + class TUrlPart: public TInputRangeAdaptor<TUrlPart> { - public: + public: TUrlPart(const TStringBuf& url) : Url_(url) { - } - - NStlIterator::TProxy<TStringBuf> Next() { - return Url_.NextTok('/'); - } - - private: - TStringBuf Url_; - }; - - Y_UNIT_TEST(TUrlPart) { + } + + NStlIterator::TProxy<TStringBuf> Next() { + return Url_.NextTok('/'); + } + + private: + TStringBuf Url_; + }; + + Y_UNIT_TEST(TUrlPart) { const TVector<TStringBuf> expected = {TStringBuf("yandex.ru"), TStringBuf("search?")}; - auto expected_part = expected.begin(); + auto expected_part = expected.begin(); for (const TStringBuf& part : TUrlPart(TStringBuf("yandex.ru/search?"))) { UNIT_ASSERT_VALUES_EQUAL(part, *expected_part); ++expected_part; - } + } UNIT_ASSERT(expected_part == expected.end()); - } -} + } +} |