1 // 2006-11-25 Paolo Carlini <pcarlini@suse.de>
3 // Copyright (C) 2006, 2007 Free Software Foundation, Inc.
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 2, or (at your option)
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.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
31 #include <testsuite_hooks.h>
33 // A few tests for equal_range, in the occasion of libstdc++/29385.
36 bool test
__attribute__((unused
)) = true;
40 typedef set
<int>::iterator iterator
;
41 typedef pair
<iterator
, bool> insert_return_type
;
42 pair
<iterator
, iterator
> pp0
;
44 pp0
= s0
.equal_range(1);
45 VERIFY( s0
.count(1) == 0 );
46 VERIFY( pp0
.first
== s0
.end() );
47 VERIFY( pp0
.second
== s0
.end() );
49 insert_return_type irt0
= s0
.insert(1);
50 insert_return_type irt1
= s0
.insert(2);
51 insert_return_type irt2
= s0
.insert(3);
53 pp0
= s0
.equal_range(2);
54 VERIFY( s0
.count(2) == 1 );
55 VERIFY( *pp0
.first
== 2 );
56 VERIFY( *pp0
.second
== 3 );
57 VERIFY( pp0
.first
== irt1
.first
);
58 VERIFY( --pp0
.first
== irt0
.first
);
59 VERIFY( pp0
.second
== irt2
.first
);
62 insert_return_type irt3
= s0
.insert(3);
63 insert_return_type irt4
= s0
.insert(4);
65 pp0
= s0
.equal_range(3);
66 VERIFY( s0
.count(3) == 1 );
67 VERIFY( *pp0
.first
== 3 );
68 VERIFY( *pp0
.second
== 4 );
69 VERIFY( pp0
.first
== irt2
.first
);
70 VERIFY( --pp0
.first
== irt1
.first
);
71 VERIFY( pp0
.second
== irt4
.first
);
73 insert_return_type irt5
= s0
.insert(0);
78 pp0
= s0
.equal_range(1);
79 VERIFY( s0
.count(1) == 1 );
80 VERIFY( *pp0
.first
== 1 );
81 VERIFY( *pp0
.second
== 2 );
82 VERIFY( pp0
.first
== irt0
.first
);
83 VERIFY( --pp0
.first
== irt5
.first
);
84 VERIFY( pp0
.second
== irt1
.first
);
86 insert_return_type irt6
= s0
.insert(5);
90 pp0
= s0
.equal_range(5);
91 VERIFY( s0
.count(5) == 1 );
92 VERIFY( *pp0
.first
== 5 );
93 VERIFY( pp0
.first
== irt6
.first
);
94 VERIFY( --pp0
.first
== irt4
.first
);
95 VERIFY( pp0
.second
== s0
.end() );
101 pp0
= s0
.equal_range(4);
102 VERIFY( s0
.count(4) == 1 );
103 VERIFY( *pp0
.first
== 4 );
104 VERIFY( *pp0
.second
== 5 );
105 VERIFY( pp0
.first
== irt4
.first
);
106 VERIFY( --pp0
.first
== irt3
.first
);
107 VERIFY( pp0
.second
== irt6
.first
);
110 insert_return_type irt7
= s0
.insert(0);
113 pp0
= s0
.equal_range(0);
114 VERIFY( s0
.count(0) == 1 );
115 VERIFY( *pp0
.first
== 0 );
116 VERIFY( *pp0
.second
== 1 );
117 VERIFY( pp0
.first
== irt5
.first
);
118 VERIFY( pp0
.first
== s0
.begin() );
119 VERIFY( pp0
.second
== irt0
.first
);
121 pp0
= s0
.equal_range(1);
122 VERIFY( s0
.count(1) == 1 );
123 VERIFY( *pp0
.first
== 1 );
124 VERIFY( *pp0
.second
== 2 );
125 VERIFY( pp0
.first
== irt0
.first
);
126 VERIFY( --pp0
.first
== irt7
.first
);
127 VERIFY( pp0
.second
== irt1
.first
);