@@ -13,30 +13,46 @@ using Vec = const std::vector<int>;
1313TEST_CASE (" filter: handles different callable types" , " [filter]" ) {
1414 Vec ns = {1 , 2 , 5 , 6 , 3 , 1 , 7 , -1 , 5 };
1515 Vec vc = {1 , 2 , 3 , 1 , -1 };
16+ std::vector<int > v;
1617 SECTION (" with function pointer" ) {
1718 auto f = filter (less_than_five, ns);
18- Vec v (std::begin (f), std::end (f));
19- REQUIRE (v == vc);
19+ v = Vec (std::begin (f), std::end (f));
2020 }
2121
2222 SECTION (" with callable object" ) {
2323 auto f = filter (LessThanValue{5 }, ns);
24- Vec v (std::begin (f), std::end (f));
25- REQUIRE (v == vc);
24+ v = Vec (std::begin (f), std::end (f));
25+ }
26+
27+ SECTION (" with lvalue callable object" ) {
28+ auto lt = LessThanValue{5 };
29+ SECTION (" normal call" ) {
30+ auto f = filter (lt, ns);
31+ v = Vec (std::begin (f), std::end (f));
32+ }
33+ SECTION (" pipe" ) {
34+ auto f = ns | filter (lt);
35+ v = Vec (std::begin (f), std::end (f));
36+ }
2637 }
2738
2839 SECTION (" with move-only callable object" ) {
29- auto f = filter (MoveOnlyLessThanValue{5 }, ns);
30- Vec v (std::begin (f), std::end (f));
31- REQUIRE (v == vc);
40+ SECTION (" normal call" ) {
41+ auto f = filter (MoveOnlyLessThanValue{5 }, ns);
42+ v = Vec (std::begin (f), std::end (f));
43+ }
44+ SECTION (" pipe" ) {
45+ auto f = ns | filter (MoveOnlyLessThanValue{5 });
46+ v = Vec (std::begin (f), std::end (f));
47+ }
3248 }
3349
3450 SECTION (" with lambda" ) {
3551 auto ltf = [](int i) { return i < 5 ; };
3652 auto f = filter (ltf, ns);
37- Vec v (std::begin (f), std::end (f));
38- REQUIRE (v == vc);
53+ v = Vec (std::begin (f), std::end (f));
3954 }
55+ REQUIRE (v == vc);
4056}
4157
4258TEST_CASE (" filter: handles pointer to member" , " [filter]" ) {
0 commit comments