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 multiset
<int>::iterator iterator
;
41 pair
<iterator
, iterator
> pp0
;
43 pp0
= ms0
.equal_range(1);
44 VERIFY( ms0
.count(1) == 0 );
45 VERIFY( pp0
.first
== ms0
.end() );
46 VERIFY( pp0
.second
== ms0
.end() );
48 iterator iter0
= ms0
.insert(1);
49 iterator iter1
= ms0
.insert(2);
50 iterator iter2
= ms0
.insert(3);
52 pp0
= ms0
.equal_range(2);
53 VERIFY( ms0
.count(2) == 1 );
54 VERIFY( *pp0
.first
== 2 );
55 VERIFY( *pp0
.second
== 3 );
56 VERIFY( pp0
.first
== iter1
);
57 VERIFY( --pp0
.first
== iter0
);
58 VERIFY( pp0
.second
== iter2
);
61 iterator iter3
= ms0
.insert(3);
62 iterator iter4
= ms0
.insert(4);
64 pp0
= ms0
.equal_range(3);
65 VERIFY( ms0
.count(3) == 3 );
66 VERIFY( *pp0
.first
== 3 );
67 VERIFY( *pp0
.second
== 4 );
68 VERIFY( pp0
.first
== iter2
);
69 VERIFY( --pp0
.first
== iter1
);
70 VERIFY( pp0
.second
== iter4
);
72 iterator iter5
= ms0
.insert(0);
77 pp0
= ms0
.equal_range(1);
78 VERIFY( ms0
.count(1) == 4 );
79 VERIFY( *pp0
.first
== 1 );
80 VERIFY( *pp0
.second
== 2 );
81 VERIFY( pp0
.first
== iter0
);
82 VERIFY( --pp0
.first
== iter5
);
83 VERIFY( pp0
.second
== iter1
);
85 iterator iter6
= ms0
.insert(5);
89 pp0
= ms0
.equal_range(5);
90 VERIFY( ms0
.count(5) == 3 );
91 VERIFY( *pp0
.first
== 5 );
92 VERIFY( pp0
.first
== iter6
);
93 VERIFY( --pp0
.first
== iter4
);
94 VERIFY( pp0
.second
== ms0
.end() );
100 pp0
= ms0
.equal_range(4);
101 VERIFY( ms0
.count(4) == 4 );
102 VERIFY( *pp0
.first
== 4 );
103 VERIFY( *pp0
.second
== 5 );
104 VERIFY( pp0
.first
== iter4
);
105 VERIFY( --pp0
.first
== iter3
);
106 VERIFY( pp0
.second
== iter6
);
109 iterator iter7
= ms0
.insert(0);
112 pp0
= ms0
.equal_range(0);
113 VERIFY( ms0
.count(0) == 3 );
114 VERIFY( *pp0
.first
== 0 );
115 VERIFY( *pp0
.second
== 1 );
116 VERIFY( pp0
.first
== iter5
);
117 VERIFY( pp0
.first
== ms0
.begin() );
118 VERIFY( pp0
.second
== iter0
);
120 pp0
= ms0
.equal_range(1);
121 VERIFY( ms0
.count(1) == 5 );
122 VERIFY( *pp0
.first
== 1 );
123 VERIFY( *pp0
.second
== 2 );
124 VERIFY( pp0
.first
== iter0
);
125 VERIFY( --pp0
.first
== iter7
);
126 VERIFY( pp0
.second
== iter1
);