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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc3/] [libstdc++-v3/] [testsuite/] [25_algorithms/] [unique/] [moveable.cc] - Blame information for rev 516

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 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.2.8 [lib.alg.unique] Unique
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 <vector>
30
#include <algorithm>
31
#include <functional>
32
#include <testsuite_hooks.h>
33
#include <testsuite_iterators.h>
34
#include <testsuite_rvalref.h>
35
 
36
using __gnu_test::test_container;
37
using __gnu_test::forward_iterator_wrapper;
38
using __gnu_test::rvalstruct;
39
 
40
typedef test_container<rvalstruct, forward_iterator_wrapper> Container;
41
 
42
void test01()
43
{
44
  bool test __attribute__((unused)) = true;
45
 
46
  int intarray1[] = {1, 4, 4, 6, 1, 2, 2, 3, 1, 6, 6, 6, 5, 7, 5, 4, 4};
47
  int intarray2[] = {1, 1, 1, 2, 2, 1, 1, 7, 6, 6, 7, 8, 8, 8, 8, 9, 9};
48
 
49
  const int N = sizeof(intarray1) / sizeof(int);
50
 
51
  rvalstruct T1[N];
52
  rvalstruct T2[N];
53
 
54
  std::copy(intarray1,intarray1 + N, T1);
55
  std::copy(intarray2,intarray2 + N, T2);
56
 
57
  const int A1[] = {1, 4, 6, 1, 2, 3, 1, 6, 5, 7, 5, 4};
58
  const int B1[] = {1, 2, 1, 7, 6, 7, 8, 9};
59
 
60
  Container con(T1, T1 + N);
61
 
62
  VERIFY( std::unique(con.begin(), con.end()).ptr - T1 == 12 );
63
  for(int i = 0; i < 12; ++i)
64
    VERIFY( T1[i].val == A1[i] );
65
 
66
  Container con2(T2, T2 + N);
67
  VERIFY( std::unique(con2.begin(), con2.end()).ptr - T2 == 8 );
68
  for(int i = 0; i < 8; ++i)
69
    VERIFY( T2[i].val == B1[i] );
70
}
71
 
72
bool are_equal(const rvalstruct& rhs, const rvalstruct& lhs)
73
{ return rhs == lhs; }
74
 
75
void test02()
76
{
77
  bool test __attribute__((unused)) = true;
78
 
79
  int intarray1[] = {1, 4, 4, 6, 1, 2, 2, 3, 1, 6, 6, 6, 5, 7, 5, 4, 4};
80
  int intarray2[] = {1, 1, 1, 2, 2, 1, 1, 7, 6, 6, 7, 8, 8, 8, 8, 9, 9};
81
 
82
  const int N = sizeof(intarray1) / sizeof(int);
83
 
84
  rvalstruct T1[N];
85
  rvalstruct T2[N];
86
 
87
  std::copy(intarray1,intarray1 + N, T1);
88
  std::copy(intarray2,intarray2 + N, T2);
89
 
90
  const int A1[] = {1, 4, 6, 1, 2, 3, 1, 6, 5, 7, 5, 4};
91
  const int B1[] = {1, 2, 1, 7, 6, 7, 8, 9};
92
 
93
  Container con(T1, T1 + N);
94
 
95
  VERIFY( std::unique(con.begin(), con.end(), are_equal).ptr - T1 == 12 );
96
  for(int i = 0; i < 12; ++i)
97
    VERIFY( T1[i].val == A1[i] );
98
 
99
  Container con2(T2, T2 + N);
100
  VERIFY( std::unique(con2.begin(), con2.end(), are_equal).ptr - T2 == 8 );
101
  for(int i = 0; i < 8; ++i)
102
    VERIFY( T2[i].val == B1[i] );
103
}
104
 
105
int main()
106
{
107
  test01();
108
  test02();
109
  return 0;
110
}

powered by: WebSVN 2.1.0

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