]>
Commit | Line | Data |
---|---|---|
0e994557 PC |
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. | |
8 | ||
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. | |
13 | ||
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 | |
83f51799 | 16 | // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
0e994557 PC |
17 | // USA. |
18 | ||
19 | // 25.2.2 swap_ranges | |
20 | ||
21 | #include <algorithm> | |
22 | #include <testsuite_hooks.h> | |
23 | #include <testsuite_iterators.h> | |
24 | ||
25 | using __gnu_test::test_container; | |
26 | using __gnu_test::forward_iterator_wrapper; | |
27 | ||
28 | typedef test_container<int, forward_iterator_wrapper> Container; | |
29 | ||
30 | ||
31 | void | |
32 | test1() | |
33 | { | |
34 | bool test __attribute__((unused)) = true; | |
35 | int array1[]={1, 2}; | |
36 | int array2[]={3, 4}; | |
37 | Container con1(array1, array1 + 2); | |
38 | Container con2(array2, array2 + 2); | |
39 | VERIFY(std::swap_ranges(con1.begin(), con1.end(), con2.begin()).ptr == | |
40 | array2 + 2); | |
41 | VERIFY(array1[0] == 3 && array1[1] == 4 && array2[0] == 1 && array2[1] == 2); | |
42 | } | |
43 | ||
44 | void | |
45 | test2() | |
46 | { | |
47 | bool test __attribute__((unused)) = true; | |
48 | int array1[] = {1}; | |
49 | int array2[] = {1}; | |
50 | Container con1(array1, array1); | |
51 | Container con2(array2, array2); | |
52 | VERIFY(swap_ranges(con1.begin(), con1.end(), con2.begin()).ptr == array2); | |
53 | } | |
54 | ||
55 | int | |
56 | main() | |
57 | { | |
58 | test1(); | |
59 | test2(); | |
60 | } |