@@ -10,6 +10,51 @@ using iter::dropwhile;
1010
1111using Vec = const std::vector<int >;
1212
13+ TEST_CASE (" dropwhile: handles different callable types" , " [dropwhile]" ) {
14+ Vec ns = {1 , 3 , 4 , 20 , 2 , 4 , 6 , 8 };
15+ Vec vc = {20 , 2 , 4 , 6 , 8 };
16+ std::vector<int > v;
17+ SECTION (" with function pointer" ) {
18+ auto d = dropwhile (less_than_five, ns);
19+ v = Vec (std::begin (d), std::end (d));
20+ }
21+
22+ SECTION (" with callable object" ) {
23+ auto d = dropwhile (LessThanValue{5 }, ns);
24+ v = Vec (std::begin (d), std::end (d));
25+ }
26+
27+ SECTION (" with lvalue callable object" ) {
28+ auto lt = LessThanValue{5 };
29+ SECTION (" normal call" ) {
30+ auto d = dropwhile (lt, ns);
31+ v = Vec (std::begin (d), std::end (d));
32+ }
33+ SECTION (" pipe" ) {
34+ auto d = ns | dropwhile (lt);
35+ v = Vec (std::begin (d), std::end (d));
36+ }
37+ }
38+
39+ SECTION (" with move-only callable object" ) {
40+ SECTION (" normal call" ) {
41+ auto d = dropwhile (MoveOnlyLessThanValue{5 }, ns);
42+ v = Vec (std::begin (d), std::end (d));
43+ }
44+ SECTION (" pipe" ) {
45+ auto d = ns | dropwhile (MoveOnlyLessThanValue{5 });
46+ v = Vec (std::begin (d), std::end (d));
47+ }
48+ }
49+
50+ SECTION (" with lambda" ) {
51+ auto ltf = [](int i) { return i < 5 ; };
52+ auto d = dropwhile (ltf, ns);
53+ v = Vec (std::begin (d), std::end (d));
54+ }
55+ REQUIRE (v == vc);
56+ }
57+
1358TEST_CASE (" dropwhile: skips initial elements" , " [dropwhile]" ) {
1459 Vec ns{1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 };
1560 std::vector<int > v;
0 commit comments