Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libstdc++-v3 / testsuite / 25_algorithms / partial_sort_copy / 1.cc
blob9aa0f78612bf3970b7301a8cc0bedb8835d78886
1 // Copyright (C) 2005 Free Software Foundation, Inc.
2 //
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 2, or (at your option)
7 // any later version.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING. If not, write to the Free
16 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17 // USA.
19 // 25.3.1.4 [lib.partial.sort.copy]
21 #include <algorithm>
22 #include <testsuite_hooks.h>
23 #include <testsuite_iterators.h>
25 using __gnu_test::test_container;
26 using __gnu_test::random_access_iterator_wrapper;
27 using __gnu_test::input_iterator_wrapper;
28 using std::partial_sort_copy;
30 typedef test_container<int, random_access_iterator_wrapper> Rcontainer;
31 typedef test_container<int, input_iterator_wrapper> Icontainer;
33 void
34 test1()
36 int array[]={2,1,0};
37 Rcontainer rcon1(array, array);
38 Rcontainer rcon2(array, array + 2);
39 Icontainer icon1(array, array);
40 Icontainer icon2(array, array + 2);
41 partial_sort_copy(icon1.begin(), icon1.end(), rcon1.begin(), rcon1.end());
42 partial_sort_copy(icon1.begin(), icon1.end(), rcon2.begin(), rcon2.end());
43 partial_sort_copy(icon2.begin(), icon2.end(), rcon1.begin(), rcon1.end());
44 partial_sort_copy(icon2.begin(), icon2.end(), rcon2.begin(), rcon2.end());
47 void
48 test2()
50 int array1[] = {4, 3, 2, 1, 0};
51 int array2[5];
52 Icontainer icon(array1, array1 + 5);
53 Rcontainer rcon(array2, array2 + 5);
54 partial_sort_copy(icon.begin(), icon.end(), rcon.begin(), rcon.end());
55 VERIFY(array2[0] == 0 && array2[1] == 1 && array2[2] == 2 &&
56 array2[3] == 3 && array2[4] == 4);
59 void
60 test3()
62 int array1[] = {4, 0, 1, 3, 2};
63 int array2[5];
64 Icontainer icon(array1, array1 + 5);
65 Rcontainer rcon(array2, array2 + 2);
66 partial_sort_copy(icon.begin(), icon.end(), rcon.begin(), rcon.end());
67 VERIFY(array2[0] == 0 && array2[1] == 1);
70 void
71 test4()
73 int array1[] = {4, 1, 3, 2, 0};
74 int array2[20];
75 Icontainer icon(array1, array1 + 5);
76 Rcontainer rcon(array2, array2 + 20);
77 partial_sort_copy(icon.begin(), icon.end(), rcon.begin(), rcon.end());
78 VERIFY(array2[0] == 0 && array2[1] == 1 && array2[2] == 2 &&
79 array2[3] == 3 && array2[4] == 4);
82 int
83 main()
85 test1();
86 test2();
87 test3();
88 test4();