OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [libstdc++-v3/] [testsuite/] [25_algorithms/] [rotate/] [1.cc] - Blame information for rev 424

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
// Copyright (C) 2005, 2009 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 3, 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 COPYING3.  If not see
16
// <http://www.gnu.org/licenses/>.
17
 
18
// 25.2.10 rotate
19
 
20
#include <algorithm>
21
#include <testsuite_hooks.h>
22
#include <testsuite_iterators.h>
23
 
24
using __gnu_test::test_container;
25
using __gnu_test::forward_iterator_wrapper;
26
using __gnu_test::bidirectional_iterator_wrapper;
27
using __gnu_test::random_access_iterator_wrapper;
28
 
29
typedef test_container<int, forward_iterator_wrapper> Fcontainer;
30
typedef test_container<int, bidirectional_iterator_wrapper> Bcontainer;
31
typedef test_container<int, random_access_iterator_wrapper> Rcontainer;
32
 
33
 
34
 
35
void
36
test1()
37
{
38
  bool test __attribute__((unused)) = true;
39
  int array[]={1};
40
  Fcontainer fcon(array, array);
41
  Bcontainer bcon(array, array);
42
  Rcontainer rcon(array, array);
43
  std::rotate(fcon.begin(), fcon.begin(), fcon.end());
44
  std::rotate(bcon.begin(), bcon.begin(), bcon.end());
45
  std::rotate(rcon.begin(), rcon.begin(), rcon.end());
46
}
47
 
48
void
49
test2()
50
{
51
  bool test __attribute__((unused)) = true;
52
  int array[] = {1};
53
  Fcontainer fcon(array, array + 1);
54
  Bcontainer bcon(array, array + 1);
55
  Rcontainer rcon(array, array + 1);
56
  std::rotate(fcon.begin(), fcon.begin(), fcon.end());
57
  std::rotate(bcon.begin(), bcon.begin(), bcon.end());
58
  std::rotate(rcon.begin(), rcon.begin(), rcon.end());
59
  std::rotate(fcon.begin(), fcon.end(), fcon.end());
60
  std::rotate(bcon.begin(), bcon.end(), bcon.end());
61
  std::rotate(rcon.begin(), rcon.end(), rcon.end());
62
}
63
 
64
void
65
test3()
66
{
67
  bool test __attribute__((unused)) = true;
68
  int array[] = {1, 2, 3, 4, 5};
69
  Fcontainer fcon(array, array + 5);
70
  Bcontainer bcon(array, array + 5);
71
  Rcontainer rcon(array, array + 5);
72
  std::rotate(fcon.begin(), fcon.it(2), fcon.end());
73
  VERIFY(array[0] == 3 && array[1] == 4 && array[2] == 5 &&
74
         array[3] == 1 && array[4] == 2);
75
  std::rotate(bcon.begin(), bcon.it(2), bcon.end());
76
  VERIFY(array[0] == 5 && array[1] == 1 && array[2] == 2 &&
77
         array[3] == 3 && array[4] == 4);
78
  std::rotate(rcon.begin(), rcon.it(2), rcon.end());
79
  VERIFY(array[0] == 2 && array[1] == 3 && array[2] == 4 &&
80
         array[3] == 5 && array[4] == 1);
81
}
82
 
83
void
84
test4()
85
{
86
  bool test __attribute__((unused)) = true;
87
  int array[] = {1, 2, 3, 4};
88
  Fcontainer fcon(array, array + 4);
89
  Bcontainer bcon(array, array + 4);
90
  Rcontainer rcon(array, array + 4);
91
 
92
  std::rotate(fcon.begin(), fcon.it(3), fcon.end());
93
  VERIFY(array[0] == 4 && array[1] == 1 && array[2] == 2 &&
94
         array[3] == 3);
95
 
96
  std::rotate(bcon.begin(), bcon.it(3), bcon.end());
97
  VERIFY(array[0] == 3 && array[1] == 4 && array[2] == 1 &&
98
         array[3] == 2);
99
 
100
  std::rotate(rcon.begin(), rcon.it(3), rcon.end());
101
  VERIFY(array[0] == 2 && array[1] == 3 && array[2] == 4 &&
102
         array[3] == 1);
103
 
104
}
105
 
106
void
107
test5()
108
{
109
  bool test __attribute__((unused)) = true;
110
  int array[] = {1, 2, 3, 4};
111
  Rcontainer con(array, array + 4);
112
  std::rotate(con.begin(), con.it(2), con.end());
113
  VERIFY(array[0] == 3 && array[1] == 4 && array[2] == 1 &&
114
         array[3] == 2);
115
}
116
 
117
int
118
main()
119
{
120
  test1();
121
  test2();
122
  test3();
123
  test4();
124
  test5();
125
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.