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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libstdc++-v3/] [testsuite/] [25_algorithms/] [rotate/] [moveable.cc] - Blame information for rev 820

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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