Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / libc++ / trunk / test / containers / sequences / forwardlist / forwardlist.ops / remove_if.pass.cpp
index 4c4e80c..ed408fb 100644 (file)
@@ -16,6 +16,8 @@
 #include <cassert>
 
 #include "min_allocator.h"
+#include "counting_predicates.hpp"
+
 
 bool g(int i)
 {
@@ -26,98 +28,128 @@ int main()
 {
     {
         typedef int T;
+        typedef unary_counting_predicate<bool(*)(T), T> Predicate;
         typedef std::forward_list<T> C;
         const T t1[] = {0, 5, 5, 0, 0, 0, 5};
         const T t2[] = {5, 5, 5};
         C c1(std::begin(t1), std::end(t1));
         C c2(std::begin(t2), std::end(t2));
-        c1.remove_if(g);
+        Predicate cp(g);
+        c1.remove_if(std::ref(cp));
         assert(c1 == c2);
+        assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
     }
     {
         typedef int T;
+        typedef unary_counting_predicate<bool(*)(T), T> Predicate;
         typedef std::forward_list<T> C;
         const T t1[] = {0, 0, 0, 0};
         C c1(std::begin(t1), std::end(t1));
         C c2;
-        c1.remove_if(g);
+        Predicate cp(g);
+        c1.remove_if(std::ref(cp));
         assert(c1 == c2);
+        assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
     }
     {
         typedef int T;
+        typedef unary_counting_predicate<bool(*)(T), T> Predicate;
         typedef std::forward_list<T> C;
         const T t1[] = {5, 5, 5};
         const T t2[] = {5, 5, 5};
         C c1(std::begin(t1), std::end(t1));
         C c2(std::begin(t2), std::end(t2));
-        c1.remove_if(g);
+        Predicate cp(g);
+        c1.remove_if(std::ref(cp));
         assert(c1 == c2);
+        assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
     }
     {
         typedef int T;
+        typedef unary_counting_predicate<bool(*)(T), T> Predicate;
         typedef std::forward_list<T> C;
         C c1;
         C c2;
-        c1.remove_if(g);
+        Predicate cp(g);
+        c1.remove_if(std::ref(cp));
         assert(c1 == c2);
+        assert(cp.count() == 0);
     }
     {
         typedef int T;
+        typedef unary_counting_predicate<bool(*)(T), T> Predicate;
         typedef std::forward_list<T> C;
         const T t1[] = {5, 5, 5, 0};
         const T t2[] = {5, 5, 5};
         C c1(std::begin(t1), std::end(t1));
         C c2(std::begin(t2), std::end(t2));
-        c1.remove_if(g);
+        Predicate cp(g);
+        c1.remove_if(std::ref(cp));
         assert(c1 == c2);
+        assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
     }
 #if __cplusplus >= 201103L
     {
         typedef int T;
+        typedef unary_counting_predicate<bool(*)(T), T> Predicate;
         typedef std::forward_list<T, min_allocator<T>> C;
         const T t1[] = {0, 5, 5, 0, 0, 0, 5};
         const T t2[] = {5, 5, 5};
         C c1(std::begin(t1), std::end(t1));
         C c2(std::begin(t2), std::end(t2));
-        c1.remove_if(g);
+        Predicate cp(g);
+        c1.remove_if(std::ref(cp));
         assert(c1 == c2);
+        assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
     }
     {
         typedef int T;
+        typedef unary_counting_predicate<bool(*)(T), T> Predicate;
         typedef std::forward_list<T, min_allocator<T>> C;
         const T t1[] = {0, 0, 0, 0};
         C c1(std::begin(t1), std::end(t1));
         C c2;
-        c1.remove_if(g);
+        Predicate cp(g);
+        c1.remove_if(std::ref(cp));
         assert(c1 == c2);
+        assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
     }
     {
         typedef int T;
+        typedef unary_counting_predicate<bool(*)(T), T> Predicate;
         typedef std::forward_list<T, min_allocator<T>> C;
         const T t1[] = {5, 5, 5};
         const T t2[] = {5, 5, 5};
         C c1(std::begin(t1), std::end(t1));
         C c2(std::begin(t2), std::end(t2));
-        c1.remove_if(g);
+        Predicate cp(g);
+        c1.remove_if(std::ref(cp));
         assert(c1 == c2);
+        assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
     }
     {
         typedef int T;
+        typedef unary_counting_predicate<bool(*)(T), T> Predicate;
         typedef std::forward_list<T, min_allocator<T>> C;
         C c1;
         C c2;
-        c1.remove_if(g);
+        Predicate cp(g);
+        c1.remove_if(std::ref(cp));
         assert(c1 == c2);
+        assert(cp.count() == 0);
     }
     {
         typedef int T;
+        typedef unary_counting_predicate<bool(*)(T), T> Predicate;
         typedef std::forward_list<T, min_allocator<T>> C;
         const T t1[] = {5, 5, 5, 0};
         const T t2[] = {5, 5, 5};
         C c1(std::begin(t1), std::end(t1));
         C c2(std::begin(t2), std::end(t2));
-        c1.remove_if(g);
+        Predicate cp(g);
+        c1.remove_if(std::ref(cp));
         assert(c1 == c2);
+        assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
     }
 #endif
 }