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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libstdc++-v3/] [testsuite/] [25_algorithms/] [prev_permutation/] [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) 2009, 2010, 2011 Free Software Foundation, Inc.
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
8
// Free Software Foundation; either version 3, or (at your option)
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
17
// with this library; see the file COPYING3.  If not see
18
// <http://www.gnu.org/licenses/>.
19
 
20
// 25.3.9 [lib.alg.permutation.generators]
21
 
22
#include <algorithm>
23
#include <testsuite_hooks.h>
24
#include <testsuite_iterators.h>
25
#include <testsuite_rvalref.h>
26
 
27
using __gnu_test::test_container;
28
using __gnu_test::bidirectional_iterator_wrapper;
29
using __gnu_test::rvalstruct;
30
using std::prev_permutation;
31
 
32
typedef test_container<rvalstruct, bidirectional_iterator_wrapper> Container;
33
 
34
void
35
test1()
36
{
37
  bool test __attribute__((unused)) = true;
38
 
39
  // Note: The standard is unclear on what should happen in this case.
40
  // This seems the only really sensible behaviour, and what is done.
41
  rvalstruct array[] = {0};
42
  Container con(array, array);
43
  VERIFY( !prev_permutation(con.begin(), con.end()) );
44
}
45
 
46
void
47
test2()
48
{
49
  bool test __attribute__((unused)) = true;
50
 
51
  rvalstruct array[] = {0};
52
  Container con(array, array + 1);
53
  VERIFY( !prev_permutation(con.begin(), con.end()) );
54
}
55
 
56
void
57
test3()
58
{
59
  bool test __attribute__((unused)) = true;
60
 
61
  rvalstruct array[] = {3, 0};
62
  Container con(array, array + 2);
63
  VERIFY( prev_permutation(con.begin(), con.end()) );
64
  VERIFY( array[0] == 0 && array[1] == 3 );
65
  VERIFY( !prev_permutation(con.begin(), con.end()) );
66
  VERIFY( array[0] == 3 && array[1] == 0 );
67
}
68
 
69
void
70
test4()
71
{
72
  bool test __attribute__((unused)) = true;
73
 
74
  int array[6] = {5, 4, 3, 2, 1, 0};
75
  for(int i = 0 ; i < 719; ++i)
76
    {
77
      rvalstruct temp_array[6];
78
      std::copy(array, array + 6, temp_array);
79
      Container con(temp_array, temp_array + 6);
80
      VERIFY( prev_permutation(array, array + 6) );
81
 
82
// XXX FIXME:  parallel-mode should deal correctly with moveable-only types
83
// per C++0x, at minimum smoothly fall back to serial.
84
#ifndef _GLIBCXX_PARALLEL
85
      VERIFY( !std::lexicographical_compare(temp_array, temp_array + 6,
86
                                            array, array + 6) );
87
#endif
88
    }
89
  VERIFY( !prev_permutation(array,array + 6)) ;
90
  for(int i = 0; i < 6; ++i)
91
    VERIFY( array[i] == (5 - i) );
92
}
93
 
94
bool
95
are_ordered(const rvalstruct& lhs, const rvalstruct& rhs)
96
{ return lhs < rhs; }
97
 
98
void
99
test5()
100
{
101
  bool test __attribute__((unused)) = true;
102
 
103
  int array[6] = {5, 4, 3, 2, 1, 0};
104
  for(int i = 0 ; i < 719; ++i)
105
    {
106
      rvalstruct temp_array[6];
107
      std::copy(array, array + 6, temp_array);
108
      Container con(temp_array, temp_array + 6);
109
      VERIFY( prev_permutation(array, array + 6, are_ordered) );
110
 
111
// XXX FIXME:  parallel-mode should deal correctly with moveable-only types
112
// per C++0x, at minimum smoothly fall back to serial.
113
#ifndef _GLIBCXX_PARALLEL
114
      VERIFY( !std::lexicographical_compare(temp_array, temp_array + 6,
115
                                            array, array + 6, are_ordered) );
116
#endif
117
    }
118
  VERIFY( !prev_permutation(array,array + 6, are_ordered) );
119
  for(int i = 0; i < 6; ++i)
120
    VERIFY( array[i] == (5 - i) );
121
}
122
 
123
int main()
124
{
125
  test1();
126
  test2();
127
  test3();
128
  test4();
129
  test5();
130
  return 0;
131
}

powered by: WebSVN 2.1.0

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