MCPcopy Create free account
hub / github.com/catboost/catboost / TEST

Function TEST

library/cpp/iterator/ut/mapped_ut.cpp:18–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16}
17
18TEST(TIterator, TMappedIteratorTest) {
19 TVector<int> x = {1, 2, 3, 4, 5};
20 auto it = MakeMappedIterator(x.begin(), [](int x) { return x + 7; });
21
22 EXPECT_EQ(*it, 8);
23 EXPECT_EQ(it[2], 10);
24
25 TVector<std::pair<int, int>> pairs = {{1, 2}, {3, 4}, {5, 6}};
26 auto firstIt = MakeMappedIterator(pairs.begin(), TSelectFirst{});
27 EXPECT_EQ(*std::next(firstIt, 0), 1);
28 EXPECT_EQ(*std::next(firstIt, 1), 3);
29 EXPECT_EQ(*std::next(firstIt, 2), 5);
30#if defined(_compiler_clang_) && defined(_linux_)
31 static_assert(sizeof(pairs.begin()) == sizeof(firstIt), "empty mapper should not add size overhead"); // this check expected to hold, but not guaranteed to
32#endif
33}
34
35TEST(TIterator, TMappedRangeTest) {
36 TVector<int> x = {1, 2, 3, 4, 5};

Callers

nothing calls this directly

Calls 6

MakeMappedIteratorFunction · 0.85
MakeMappedRangeFunction · 0.85
ElementsAreFunction · 0.85
nextFunction · 0.50
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected