Skip to content

Commit

Permalink
Add offset test
Browse files Browse the repository at this point in the history
  • Loading branch information
msft-cpp-blog committed Nov 9, 2023
1 parent 321c6f6 commit 08fc853
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion tests/stride.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ TEST_CASE("offset") {
std::list<int> l {0, 1, 2, 3};

{
//
auto v = tl::stride_view(l, 3);
auto it = v.begin();
REQUIRE(*it == 0);
Expand All @@ -86,4 +85,30 @@ TEST_CASE("offset") {
--it;
REQUIRE(*it == 3);
}
}

TEST_CASE("offset") {
std::list<int> l{ 0, 1, 2, 3 };

{
auto v = tl::stride_view(l, 3);
auto it = v.begin();
REQUIRE(*it == 0);
++it;
REQUIRE(*it == 3);
++it;
--it;
REQUIRE(*it == 3);
}

{
auto v = tl::stride_view(l | std::views::filter([](auto&&) { return true; }), 3);
auto it = v.begin();
REQUIRE(*it == 0);
++it;
REQUIRE(*it == 3);
++it;
--it;
REQUIRE(*it == 3);
}
}

0 comments on commit 08fc853

Please sign in to comment.