Skip to content

Commit cea0bf7

Browse files
committed
tests that filter drops nullptrs by identity
1 parent a9c719a commit cea0bf7

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

test/test_filter.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ TEST_CASE("filter: using identity", "[filter]") {
7070
REQUIRE(v == vc);
7171
}
7272

73+
TEST_CASE("filter: skips null pointers", "[filter]") {
74+
int a = 1;
75+
int b = 2;
76+
const std::vector<int *> ns = {0, &a, nullptr, nullptr, &b, nullptr};
77+
78+
auto f = filter(ns);
79+
const std::vector<int *> v(std::begin(f), std::end(f));
80+
const std::vector<int *> vc = {&a, &b};
81+
REQUIRE( v == vc );
82+
}
83+
7384
TEST_CASE("filter: binds to lvalues, moves rvales", "[filter]") {
7485
itertest::BasicIterable<int> bi{1, 2, 3, 4};
7586

0 commit comments

Comments
 (0)