Skip to content

Commit 73cbe05

Browse files
Unit test for ranget drop and skip
This tests that these operations behave as expected and gives examples on how to use them.
1 parent 99c2e42 commit 73cbe05

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

unit/util/range.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,34 @@ SCENARIO("range tests", "[core][util][range]")
5757
++it;
5858
REQUIRE(it == filtered_range.end());
5959
}
60+
THEN("Drop first 2 elements")
61+
{
62+
auto range = make_range(list);
63+
range.drop(2);
64+
auto it = range.begin();
65+
REQUIRE(*it == "acdef");
66+
range.drop(1);
67+
REQUIRE(range.empty());
68+
}
69+
THEN("Drop first 5 elements")
70+
{
71+
auto range = make_range(list);
72+
range.drop(5);
73+
REQUIRE(range.empty());
74+
}
75+
THEN("Skip first 2 elements")
76+
{
77+
auto range = make_range(list).skip(2);
78+
auto it = range.begin();
79+
REQUIRE(*it == "acdef");
80+
range.drop(1);
81+
REQUIRE(range.empty());
82+
}
83+
THEN("Skip first 5 elements")
84+
{
85+
auto range = make_range(list).skip(5);
86+
REQUIRE(range.empty());
87+
}
6088
THEN(
6189
"A const instance of a `filter_iteratort` can mutate the input "
6290
"collection.")

0 commit comments

Comments
 (0)