OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc3/] [libstdc++-v3/] [testsuite/] [tr1/] [6_containers/] [tuple/] [cons/] [big_tuples.cc] - Blame information for rev 516

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
// 2004-09-23 Chris Jefferson <chris@bubblescope.net>
2
 
3
// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
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
// Tuple
22
 
23
#include <tr1/tuple>
24
#include <testsuite_hooks.h>
25
 
26
using namespace std::tr1;
27
using std::pair;
28
 
29
// A simple class without conversions to check some things
30
struct foo
31
{ };
32
 
33
void
34
test_constructors()
35
{
36
  bool test __attribute__((unused)) = true;
37
 
38
  int x1=0,x2=0;
39
  const int &z1=x1;
40
 
41
  // Test empty constructor
42
  tuple<> ta __attribute__((unused));
43
  tuple<int,int> tb;
44
  // Test construction from values
45
  tuple<int,int> tc(x1,x2);
46
  tuple<int,int&> td(x1,x2);
47
  tuple<const int&> te(z1);
48
  x1=1;
49
  x2=1;
50
  VERIFY(get<0>(td) == 0 && get<1>(td) == 1 && get<0>(te) == 1);
51
 
52
  // Test identical tuple copy constructor
53
  tuple<int,int> tf(tc);
54
  tuple<int,int> tg(td);
55
  tuple<const int&> th(te);
56
  // Test different tuple copy constructor
57
  tuple<int,double> ti(tc);
58
  tuple<int,double> tj(td);
59
  // Test constructing from a pair
60
  pair<int,int> pair1(1,1);
61
  const pair<int,int> pair2(pair1);
62
  tuple<int,int> tl(pair1);
63
  tuple<int,const int&> tm(pair1);
64
  tuple<int,int> tn(pair2);
65
  tuple<int,const int&> to(pair2);
66
}
67
 
68
int
69
main(void)
70
{
71
  //test construction
72
  typedef tuple<int,int,int,int,int,int,int,int,int,int> type1;
73
  type1 a(0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
74
  type1 b(0, 0, 0, 0, 0, 0, 0, 0, 0, 2);
75
  type1 c(a);
76
  typedef tuple<int,int,int,int,int,int,int,int,int,char> type2;
77
  type2 d(0, 0, 0, 0, 0, 0, 0, 0, 0, 3);
78
  type1 e(d);
79
  typedef tuple<foo,int,int,int,int,int,int,int,int,foo> type3;
80
  // get
81
  VERIFY(get<9>(a)==1 && get<9>(b)==2);
82
  // comparisons
83
  VERIFY(a==a && !(a!=a) && a<=a && a>=a && !(a<a) && !(a>a));
84
  VERIFY(!(a==b) && a!=b && a<=b && a<b && !(a>=b) && !(a>b));
85
  //tie
86
  {
87
    int i = 0;
88
  tie(ignore, ignore, ignore, ignore, ignore, ignore, ignore, ignore,
89
      ignore, i) = a;
90
  VERIFY(i == 1);
91
  }
92
  //test_assignment
93
  a=d;
94
  a=b;
95
  //make_tuple
96
  make_tuple(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
97
 
98
  //tuple_size
99
  VERIFY(tuple_size<type3>::value == 10);
100
  //tuple_element
101
  {
102
    foo q1;
103
    tuple_element<0,type3>::type q2(q1);
104
    tuple_element<9,type3>::type q3(q1);
105
  }
106
 
107
}
108
 

powered by: WebSVN 2.1.0

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