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

Subversion Repositories openrisc

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

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
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.3.1 algorithms, sort()
22
 
23
#undef _GLIBCXX_CONCEPT_CHECKS
24
 
25
// XXX FIXME:  parallel-mode should deal correctly with moveable-only types
26
// per C++0x, at minimum smoothly fall back to serial.
27
#undef _GLIBCXX_PARALLEL
28
 
29
#include <algorithm>
30
#include <testsuite_hooks.h>
31
#include <testsuite_iterators.h>
32
#include <testsuite_rvalref.h>
33
 
34
using __gnu_test::test_container;
35
using __gnu_test::random_access_iterator_wrapper;
36
using __gnu_test::rvalstruct;
37
using std::partial_sort;
38
 
39
typedef test_container<rvalstruct, random_access_iterator_wrapper> Container;
40
 
41
const int A[] = {10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7,
42
                 17, 8, 18, 9, 19};
43
const int N = sizeof(A) / sizeof(int);
44
 
45
// 25.3.1.1 sort()
46
void
47
test01()
48
{
49
  bool test __attribute__((unused)) = true;
50
 
51
  rvalstruct s1[N];
52
  std::copy(A, A + N, s1);
53
  Container con(s1, s1 + N);
54
  std::sort(con.begin(), con.end());
55
  VERIFY( s1[0].valid );
56
  for(int i = 1; i < N; ++i)
57
    VERIFY( s1[i].val>s1[i-1].val && s1[i].valid );
58
}
59
 
60
bool order(const rvalstruct& lhs, const rvalstruct& rhs)
61
{ return lhs < rhs; }
62
 
63
// 25.3.1.1 sort()
64
void
65
test02()
66
{
67
  bool test __attribute__((unused)) = true;
68
 
69
  rvalstruct s1[N];
70
  std::copy(A, A + N, s1);
71
  Container con(s1, s1 + N);
72
  std::sort(con.begin(), con.end(), order);
73
  VERIFY( s1[0].valid );
74
  for(int i = 1; i < N; ++i)
75
    VERIFY( s1[i].val>s1[i-1].val && s1[i].valid );
76
}
77
 
78
int
79
main()
80
{
81
  test01();
82
  test02();
83
  return 0;
84
}

powered by: WebSVN 2.1.0

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