Skip to content

Commit 5dd6719

Browse files
committed
Tests dropwhile with pointer to member
1 parent 11f476f commit 5dd6719

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

test/test_dropwhile.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,33 @@ TEST_CASE("dropwhile: skips initial elements", "[dropwhile]") {
4141
REQUIRE(v == vc);
4242
}
4343

44+
TEST_CASE("dropwhile: handles pointer to member", "[dropwhile]") {
45+
using itertest::Point;
46+
const std::vector<Point> ps = {
47+
{5, 0}, {3, 5}, {2, 1}, {0, 1}, {2, 2}, {6, 0}};
48+
std::vector<Point> v;
49+
SECTION("with pointer to data member") {
50+
auto dw = dropwhile(&Point::x, ps);
51+
v.assign(std::begin(dw), std::end(dw));
52+
}
53+
54+
SECTION("with pointer to member function") {
55+
auto dw = dropwhile(&Point::get_x, ps);
56+
v.assign(std::begin(dw), std::end(dw));
57+
}
58+
59+
const std::vector<Point> vc = {{0, 1}, {2, 2}, {6, 0}};
60+
REQUIRE(v == vc);
61+
}
62+
63+
TEST_CASE("dropwhile: drop empty strings at front", "[dropwhile]") {
64+
const std::vector<std::string> words = {"", "", "check", "", "test"};
65+
auto dw = dropwhile(&std::string::empty, words);
66+
const std::vector<std::string> v(std::begin(dw), std::end(dw));
67+
const std::vector<std::string> vc = {"check", "", "test"};
68+
REQUIRE(v == vc);
69+
}
70+
4471
TEST_CASE("dropwhile: const iteration", "[dropwhile][const]") {
4572
Vec ns{1, 2, 3, 4, 5, 6, 7, 8};
4673
const auto d = dropwhile(LessThanValue{5}, ns);

0 commit comments

Comments
 (0)