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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libstdc++-v3/] [testsuite/] [23_containers/] [set/] [operations/] [1.cc] - Blame information for rev 848

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

Line No. Rev Author Line
1 742 jeremybenn
// 2006-11-25  Paolo Carlini  <pcarlini@suse.de>
2
 
3
// Copyright (C) 2006, 2007, 2009 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
 
21
#include <set>
22
#include <testsuite_hooks.h>
23
 
24
// A few tests for equal_range, in the occasion of libstdc++/29385.
25
void test01()
26
{
27
  bool test __attribute__((unused)) = true;
28
  using namespace std;
29
 
30
  set<int> s0;
31
  typedef set<int>::iterator iterator;
32
  typedef pair<iterator, bool> insert_return_type;
33
  pair<iterator, iterator> pp0;
34
 
35
  pp0 = s0.equal_range(1);
36
  VERIFY( s0.count(1) == 0 );
37
  VERIFY( pp0.first == s0.end() );
38
  VERIFY( pp0.second == s0.end() );
39
 
40
  insert_return_type irt0 = s0.insert(1);
41
  insert_return_type irt1 = s0.insert(2);
42
  insert_return_type irt2 = s0.insert(3);
43
 
44
  pp0 = s0.equal_range(2);
45
  VERIFY( s0.count(2) == 1 );
46
  VERIFY( *pp0.first == 2 );
47
  VERIFY( *pp0.second == 3 );
48
  VERIFY( pp0.first == irt1.first );
49
  VERIFY( --pp0.first == irt0.first );
50
  VERIFY( pp0.second == irt2.first );
51
 
52
  s0.insert(3);
53
  insert_return_type irt3 = s0.insert(3);
54
  insert_return_type irt4 = s0.insert(4);
55
 
56
  pp0 = s0.equal_range(3);
57
  VERIFY( s0.count(3) == 1 );
58
  VERIFY( *pp0.first == 3 );
59
  VERIFY( *pp0.second == 4 );
60
  VERIFY( pp0.first == irt2.first );
61
  VERIFY( --pp0.first == irt1.first );
62
  VERIFY( pp0.second == irt4.first );
63
 
64
  insert_return_type irt5 = s0.insert(0);
65
  s0.insert(1);
66
  s0.insert(1);
67
  s0.insert(1);
68
 
69
  pp0 = s0.equal_range(1);
70
  VERIFY( s0.count(1) == 1 );
71
  VERIFY( *pp0.first == 1 );
72
  VERIFY( *pp0.second == 2 );
73
  VERIFY( pp0.first == irt0.first );
74
  VERIFY( --pp0.first == irt5.first );
75
  VERIFY( pp0.second == irt1.first );
76
 
77
  insert_return_type irt6 = s0.insert(5);
78
  s0.insert(5);
79
  s0.insert(5);
80
 
81
  pp0 = s0.equal_range(5);
82
  VERIFY( s0.count(5) == 1 );
83
  VERIFY( *pp0.first == 5 );
84
  VERIFY( pp0.first == irt6.first );
85
  VERIFY( --pp0.first == irt4.first );
86
  VERIFY( pp0.second == s0.end() );
87
 
88
  s0.insert(4);
89
  s0.insert(4);
90
  s0.insert(4);
91
 
92
  pp0 = s0.equal_range(4);
93
  VERIFY( s0.count(4) == 1 );
94
  VERIFY( *pp0.first == 4 );
95
  VERIFY( *pp0.second == 5 );
96
  VERIFY( pp0.first == irt4.first );
97
  VERIFY( --pp0.first == irt3.first );
98
  VERIFY( pp0.second == irt6.first );
99
 
100
  s0.insert(0);
101
  insert_return_type irt7 = s0.insert(0);
102
  s0.insert(1);
103
 
104
  pp0 = s0.equal_range(0);
105
  VERIFY( s0.count(0) == 1 );
106
  VERIFY( *pp0.first == 0 );
107
  VERIFY( *pp0.second == 1 );
108
  VERIFY( pp0.first == irt5.first );
109
  VERIFY( pp0.first == s0.begin() );
110
  VERIFY( pp0.second == irt0.first );
111
 
112
  pp0 = s0.equal_range(1);
113
  VERIFY( s0.count(1) == 1 );
114
  VERIFY( *pp0.first == 1 );
115
  VERIFY( *pp0.second == 2 );
116
  VERIFY( pp0.first == irt0.first );
117
  VERIFY( --pp0.first == irt7.first );
118
  VERIFY( pp0.second == irt1.first );
119
}
120
 
121
int
122
main()
123
{
124
  test01();
125
  return 0;
126
}

powered by: WebSVN 2.1.0

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