1 // { dg-options "-std=gnu++0x" }
3 // 2008-06-26 Paolo Carlini <paolo.carlini@oracle.com>
5 // Copyright (C) 2008 Free Software Foundation, Inc.
7 // This file is part of the GNU ISO C++ Library. This library is free
8 // software; you can redistribute it and/or modify it under the
9 // terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 2, or (at your option)
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License along
19 // with this library; see the file COPYING. If not, write to the Free
20 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
24 #include <testsuite_hooks.h>
25 #include <testsuite_iterators.h>
27 using __gnu_test::test_container
;
28 using __gnu_test::input_iterator_wrapper
;
29 using __gnu_test::output_iterator_wrapper
;
31 typedef test_container
<int, input_iterator_wrapper
> Icontainer
;
32 typedef test_container
<int, output_iterator_wrapper
> Ocontainer
;
33 int array
[] = {0, 5, 2, 1, 3, 4};
42 bool test
__attribute__((unused
)) = true;
44 int true_out
[1] = { -1 };
45 int false_out
[1] = { -1 };
46 Icontainer
in_con(array
, array
);
47 Ocontainer
true_out_con(true_out
, true_out
);
48 Ocontainer
false_out_con(false_out
, false_out
);
50 std::pair
<output_iterator_wrapper
<int>, output_iterator_wrapper
<int> > res
=
51 std::partition_copy(in_con
.begin(), in_con
.end(),
52 true_out_con
.begin(), false_out_con
.begin(), pred
);
54 VERIFY( res
.first
.ptr
== true_out
);
55 VERIFY( res
.second
.ptr
== false_out
);
61 bool test
__attribute__((unused
)) = true;
63 int true_out
[1] = { -1 };
64 int false_out
[1] = { -1 };
65 Icontainer
in_con(array
, array
+ 2);
66 Ocontainer
true_out_con(true_out
, true_out
+ 1);
67 Ocontainer
false_out_con(false_out
, false_out
+ 1);
69 std::pair
<output_iterator_wrapper
<int>, output_iterator_wrapper
<int> > res
=
70 std::partition_copy(in_con
.begin(), in_con
.end(),
71 true_out_con
.begin(), false_out_con
.begin(), pred
);
73 VERIFY( res
.first
.ptr
== true_out
+ 1 );
74 VERIFY( res
.second
.ptr
== false_out
+ 1 );
75 VERIFY( true_out
[0] == 5 );
76 VERIFY( false_out
[0] == 0 );
82 bool test
__attribute__((unused
)) = true;
84 int true_out
[3] = { -1, -1, -1 };
85 int false_out
[3] = { -1, -1, -1 };
86 Icontainer
in_con(array
, array
+ 6);
87 Ocontainer
true_out_con(true_out
, true_out
+ 3);
88 Ocontainer
false_out_con(false_out
, false_out
+ 3);
90 std::pair
<output_iterator_wrapper
<int>, output_iterator_wrapper
<int> > res
=
91 std::partition_copy(in_con
.begin(), in_con
.end(),
92 true_out_con
.begin(), false_out_con
.begin(), pred
);
94 VERIFY( res
.first
.ptr
== true_out
+ 3 );
95 VERIFY( res
.second
.ptr
== false_out
+ 3 );
96 VERIFY( true_out
[0] == 5 && true_out
[1] == 3 && true_out
[2] == 4 );
97 VERIFY( false_out
[0] == 0 && false_out
[1] == 2 && false_out
[2] == 1 );