]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/25_algorithms/rotate/moveable.cc
Update copyright years in libstdc++-v3/
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 25_algorithms / rotate / moveable.cc
CommitLineData
f5783e34
CJ
1// { dg-options "-std=gnu++0x" }
2
aa118a03 3// Copyright (C) 2005-2014 Free Software Foundation, Inc.
f5783e34
CJ
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
748086b7 8// Free Software Foundation; either version 3, or (at your option)
f5783e34
CJ
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License along
748086b7
JJ
17// with this library; see the file COPYING3. If not see
18// <http://www.gnu.org/licenses/>.
f5783e34
CJ
19
20// 25.2.10 rotate
21
22// Tests rotate when an moveable class is used
23
24#undef _GLIBCXX_CONCEPT_CHECKS
25
26#include <algorithm>
27#include <testsuite_hooks.h>
28#include <testsuite_iterators.h>
29#include <testsuite_rvalref.h>
30
31using __gnu_test::test_container;
32using __gnu_test::forward_iterator_wrapper;
33using __gnu_test::bidirectional_iterator_wrapper;
34using __gnu_test::random_access_iterator_wrapper;
35using __gnu_test::rvalstruct;
36
37typedef test_container<rvalstruct, forward_iterator_wrapper> Fcontainer;
38typedef test_container<rvalstruct, bidirectional_iterator_wrapper> Bcontainer;
39typedef test_container<rvalstruct, random_access_iterator_wrapper> Rcontainer;
40
f5783e34
CJ
41void
42test1()
43{
44 bool test __attribute__((unused)) = true;
45 int data[] = {1, 2, 3, 4, 5};
46 rvalstruct array[5];
47 std::copy(data, data + 5, array);
48 Fcontainer fcon(array, array + 5);
49 Bcontainer bcon(array, array + 5);
50 Rcontainer rcon(array, array + 5);
51
52 std::rotate(fcon.begin(), fcon.it(2), fcon.end());
53 VERIFY(array[0].val == 3 && array[1].val == 4 && array[2].val == 5 &&
54 array[3].val == 1 && array[4].val == 2);
55 for(int i=0;i<5;i++)
56 VERIFY(array[i].valid == true);
57
58 std::rotate(bcon.begin(), bcon.it(2), bcon.end());
59 VERIFY(array[0].val == 5 && array[1].val == 1 && array[2].val == 2 &&
60 array[3].val == 3 && array[4].val == 4);
61 for(int i=0;i<5;i++)
62 VERIFY(array[i].valid);
63
64 std::rotate(rcon.begin(), rcon.it(2), rcon.end());
65 VERIFY(array[0].val == 2 && array[1].val == 3 && array[2].val == 4 &&
66 array[3].val == 5 && array[4].val == 1);
67 for(int i=0;i<5;i++)
68 VERIFY(array[i].valid);
69}
70
71int
72main()
73{
74 test1();
75}