Skip to content

Commit fe5e821

Browse files
committed
Adds pipe and identity dropwhile tests.
It seems like a dropwhile with identity (drop all true elements at front) would be useless, but who am I to judge..?
1 parent d0f32c4 commit fe5e821

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

test/test_dropwhile.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,15 @@ using Vec = const std::vector<int>;
1414

1515
TEST_CASE("dropwhile: skips initial elements", "[dropwhile]") {
1616
Vec ns{1, 2, 3, 4, 5, 6, 7, 8};
17-
auto d = dropwhile([](int i) { return i < 5; }, ns);
18-
Vec v(std::begin(d), std::end(d));
17+
std::vector<int> v;
18+
SECTION("Normal call") {
19+
auto d = dropwhile([](int i) { return i < 5; }, ns);
20+
v.assign(std::begin(d), std::end(d));
21+
}
22+
SECTION("Pipe") {
23+
auto d = ns | dropwhile([](int i) { return i < 5; });
24+
v.assign(std::begin(d), std::end(d));
25+
}
1926
Vec vc = {5, 6, 7, 8};
2027
REQUIRE(v == vc);
2128
}
@@ -35,6 +42,14 @@ TEST_CASE("dropwhile: skips all elements when all are true under predicate",
3542
REQUIRE(std::begin(d) == std::end(d));
3643
}
3744

45+
TEST_CASE("dropwhile: identity", "[dropwhile]") {
46+
Vec ns {1, 2, 0, 3, 1, 0};
47+
auto d = dropwhile(ns);
48+
Vec v(std::begin(d), std::end(d));
49+
Vec vc = {0, 3, 1, 0};
50+
REQUIRE(v == vc);
51+
}
52+
3853
TEST_CASE("dropwhile: empty case is empty", "[dropwhile]") {
3954
Vec ns{};
4055
auto d = dropwhile([](int i) { return i != 0; }, ns);

0 commit comments

Comments
 (0)