diff options
author | thegeorg <thegeorg@yandex-team.ru> | 2022-02-10 16:45:08 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:08 +0300 |
commit | 4e839db24a3bbc9f1c610c43d6faaaa99824dcca (patch) | |
tree | 506dac10f5df94fab310584ee51b24fc5a081c22 /library/cpp/iterator/ut/mapped_ut.cpp | |
parent | 2d37894b1b037cf24231090eda8589bbb44fb6fc (diff) | |
download | ydb-4e839db24a3bbc9f1c610c43d6faaaa99824dcca.tar.gz |
Restoring authorship annotation for <thegeorg@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/iterator/ut/mapped_ut.cpp')
-rw-r--r-- | library/cpp/iterator/ut/mapped_ut.cpp | 114 |
1 files changed, 57 insertions, 57 deletions
diff --git a/library/cpp/iterator/ut/mapped_ut.cpp b/library/cpp/iterator/ut/mapped_ut.cpp index 440cd37945..77b5d7c2f6 100644 --- a/library/cpp/iterator/ut/mapped_ut.cpp +++ b/library/cpp/iterator/ut/mapped_ut.cpp @@ -1,61 +1,61 @@ -#include <library/cpp/iterator/mapped.h> - -#include <library/cpp/testing/gtest/gtest.h> - -#include <util/generic/map.h> -#include <util/generic/vector.h> - -using namespace testing; - -TEST(TIterator, TMappedIteratorTest) { - TVector<int> x = {1, 2, 3, 4, 5}; - auto it = MakeMappedIterator(x.begin(), [](int x) { return x + 7; }); - - EXPECT_EQ(*it, 8); - EXPECT_EQ(it[2], 10); -} - -TEST(TIterator, TMappedRangeTest) { - TVector<int> x = {1, 2, 3, 4, 5}; - - EXPECT_THAT( - MakeMappedRange( - x, - [](int x) { return x + 3; } - ), - ElementsAre(4, 5, 6, 7, 8) - ); -} - -//TODO: replace with dedicated IterateKeys / IterateValues methods -TEST(TIterator, TMutableMappedRangeTest) { - TMap<int, int> points = {{1, 2}, {3, 4}}; - - EXPECT_THAT( - MakeMappedRange( - points.begin(), points.end(), - [](TMap<int, int>::value_type& kv) -> int& { return kv.second; } - ), - ElementsAre(2, 4) - ); -} - -TEST(TIterator, TOwningMappedMethodTest) { - auto range = MakeMappedRange( - TVector<std::pair<int, int>>{std::make_pair(1, 2), std::make_pair(3, 4)}, - [](auto& point) -> int& { - return point.first; +#include <library/cpp/iterator/mapped.h> + +#include <library/cpp/testing/gtest/gtest.h> + +#include <util/generic/map.h> +#include <util/generic/vector.h> + +using namespace testing; + +TEST(TIterator, TMappedIteratorTest) { + TVector<int> x = {1, 2, 3, 4, 5}; + auto it = MakeMappedIterator(x.begin(), [](int x) { return x + 7; }); + + EXPECT_EQ(*it, 8); + EXPECT_EQ(it[2], 10); +} + +TEST(TIterator, TMappedRangeTest) { + TVector<int> x = {1, 2, 3, 4, 5}; + + EXPECT_THAT( + MakeMappedRange( + x, + [](int x) { return x + 3; } + ), + ElementsAre(4, 5, 6, 7, 8) + ); +} + +//TODO: replace with dedicated IterateKeys / IterateValues methods +TEST(TIterator, TMutableMappedRangeTest) { + TMap<int, int> points = {{1, 2}, {3, 4}}; + + EXPECT_THAT( + MakeMappedRange( + points.begin(), points.end(), + [](TMap<int, int>::value_type& kv) -> int& { return kv.second; } + ), + ElementsAre(2, 4) + ); +} + +TEST(TIterator, TOwningMappedMethodTest) { + auto range = MakeMappedRange( + TVector<std::pair<int, int>>{std::make_pair(1, 2), std::make_pair(3, 4)}, + [](auto& point) -> int& { + return point.first; } - ); - EXPECT_EQ(range[0], 1); - range[0] += 1; - EXPECT_EQ(range[0], 2); - (*range.begin()) += 1; - EXPECT_EQ(range[0], 3); - for (int& y : range) { - y += 7; + ); + EXPECT_EQ(range[0], 1); + range[0] += 1; + EXPECT_EQ(range[0], 2); + (*range.begin()) += 1; + EXPECT_EQ(range[0], 3); + for (int& y : range) { + y += 7; } - EXPECT_EQ(*range.begin(), 10); - EXPECT_EQ(*(range.begin() + 1), 10); + EXPECT_EQ(*range.begin(), 10); + EXPECT_EQ(*(range.begin() + 1), 10); } |