diff options
author | pechatnov <pechatnov@yandex-team.ru> | 2022-02-10 16:48:57 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:57 +0300 |
commit | 132a3640fac343164b858d0a914e020a848a2848 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /util/generic/iterator_range_ut.cpp | |
parent | 8e9b2f8bbf4a2320f539eef5b85555f42c065425 (diff) | |
download | ydb-132a3640fac343164b858d0a914e020a848a2848.tar.gz |
Restoring authorship annotation for <pechatnov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/generic/iterator_range_ut.cpp')
-rw-r--r-- | util/generic/iterator_range_ut.cpp | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/util/generic/iterator_range_ut.cpp b/util/generic/iterator_range_ut.cpp index 60032745f5..a7e3670ae1 100644 --- a/util/generic/iterator_range_ut.cpp +++ b/util/generic/iterator_range_ut.cpp @@ -10,11 +10,11 @@ Y_UNIT_TEST_SUITE(IteratorRange) { UNIT_ASSERT(range.empty()); } - Y_UNIT_TEST(DefaultConstructorSentinel) { - TIteratorRange<int*, void*> range; - UNIT_ASSERT(range.empty()); - } - + Y_UNIT_TEST(DefaultConstructorSentinel) { + TIteratorRange<int*, void*> range; + UNIT_ASSERT(range.empty()); + } + Y_UNIT_TEST(RangeBasedForLoop) { // compileability test for (int i : TIteratorRange<int*>()) { @@ -22,13 +22,13 @@ Y_UNIT_TEST_SUITE(IteratorRange) { } } - Y_UNIT_TEST(RangeBasedForLoopSentinel) { - // compileability test - for (int i : TIteratorRange<int*, void*>()) { - Y_UNUSED(i); - } - } - + Y_UNIT_TEST(RangeBasedForLoopSentinel) { + // compileability test + for (int i : TIteratorRange<int*, void*>()) { + Y_UNUSED(i); + } + } + Y_UNIT_TEST(Works) { const int values[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; auto range = MakeIteratorRange(values, values + Y_ARRAY_SIZE(values)); @@ -37,37 +37,37 @@ Y_UNIT_TEST_SUITE(IteratorRange) { UNIT_ASSERT(!range.empty()); } - Y_UNIT_TEST(WorksSentinel) { - struct TRangeSentinel { - }; - - struct TEnumerator { - ui32 operator*() const { - return Cur; - } - - void operator++() { - ++Cur; - } - - bool operator!=(const TRangeSentinel&) const { - return Cur < End; - } - - ui32 Cur; - ui32 End; - }; - - auto range = MakeIteratorRange(TEnumerator{0, 10}, TRangeSentinel{}); - UNIT_ASSERT(!range.empty()); - - ui32 i = 0; - for (auto j : range) { - UNIT_ASSERT_VALUES_EQUAL(j, i++); - } - UNIT_ASSERT_VALUES_EQUAL(i, 10); - } - + Y_UNIT_TEST(WorksSentinel) { + struct TRangeSentinel { + }; + + struct TEnumerator { + ui32 operator*() const { + return Cur; + } + + void operator++() { + ++Cur; + } + + bool operator!=(const TRangeSentinel&) const { + return Cur < End; + } + + ui32 Cur; + ui32 End; + }; + + auto range = MakeIteratorRange(TEnumerator{0, 10}, TRangeSentinel{}); + UNIT_ASSERT(!range.empty()); + + ui32 i = 0; + for (auto j : range) { + UNIT_ASSERT_VALUES_EQUAL(j, i++); + } + UNIT_ASSERT_VALUES_EQUAL(i, 10); + } + Y_UNIT_TEST(OperatorsAndReferences) { TVector<size_t> values{1, 2, 3, 4, 5}; auto range = MakeIteratorRange(values.begin(), values.end()); |