diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:03:23 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:03:23 +0000 |
| commit | 0dc0969cd0a732760f0aa79942a04e0eaef297c4 (patch) | |
| tree | 051bdb57b1ac6ee143f61ddbb47bd0da619f6f0c /test/std/algorithms/alg.nonmodifying | |
| parent | 868847c6900e575417c03bced6e562b3af891318 (diff) | |
Notes
Diffstat (limited to 'test/std/algorithms/alg.nonmodifying')
3 files changed, 27 insertions, 7 deletions
diff --git a/test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp index 025bc06a618da..0a05c6f659ca3 100644 --- a/test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp +++ b/test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp @@ -20,17 +20,24 @@ #include "test_iterators.h" +struct eq { + eq (int val) : v(val) {} + bool operator () (int v2) const { return v == v2; } + int v; + }; + + int main() { int ia[] = {0, 1, 2, 2, 0, 1, 2, 3}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); assert(std::count_if(input_iterator<const int*>(ia), input_iterator<const int*>(ia + sa), - std::bind2nd(std::equal_to<int>(),2)) == 3); + eq(2)) == 3); assert(std::count_if(input_iterator<const int*>(ia), input_iterator<const int*>(ia + sa), - std::bind2nd(std::equal_to<int>(),7)) == 0); + eq(7)) == 0); assert(std::count_if(input_iterator<const int*>(ia), input_iterator<const int*>(ia), - std::bind2nd(std::equal_to<int>(),2)) == 0); + eq(2)) == 0); } diff --git a/test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp index bde6ff389d0cd..c942d2e38a58c 100644 --- a/test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp +++ b/test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp @@ -20,16 +20,22 @@ #include "test_iterators.h" +struct eq { + eq (int val) : v(val) {} + bool operator () (int v2) const { return v == v2; } + int v; + }; + int main() { int ia[] = {0, 1, 2, 3, 4, 5}; const unsigned s = sizeof(ia)/sizeof(ia[0]); input_iterator<const int*> r = std::find_if(input_iterator<const int*>(ia), input_iterator<const int*>(ia+s), - std::bind2nd(std::equal_to<int>(), 3)); + eq(3)); assert(*r == 3); r = std::find_if(input_iterator<const int*>(ia), input_iterator<const int*>(ia+s), - std::bind2nd(std::equal_to<int>(), 10)); + eq(10)); assert(r == input_iterator<const int*>(ia+s)); } diff --git a/test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp b/test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp index 661e643f07d14..e68344b4b259e 100644 --- a/test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp +++ b/test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp @@ -20,16 +20,23 @@ #include "test_iterators.h" +struct ne { + ne (int val) : v(val) {} + bool operator () (int v2) const { return v != v2; } + int v; + }; + + int main() { int ia[] = {0, 1, 2, 3, 4, 5}; const unsigned s = sizeof(ia)/sizeof(ia[0]); input_iterator<const int*> r = std::find_if_not(input_iterator<const int*>(ia), input_iterator<const int*>(ia+s), - std::bind2nd(std::not_equal_to<int>(), 3)); + ne(3)); assert(*r == 3); r = std::find_if_not(input_iterator<const int*>(ia), input_iterator<const int*>(ia+s), - std::bind2nd(std::not_equal_to<int>(), 10)); + ne(10)); assert(r == input_iterator<const int*>(ia+s)); } |
