1 // 2006-01-07 Paolo Carlini <pcarlini@suse.de>
3 // Copyright (C) 2006 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 // 23.3.2 Class template multimap
24 #include <testsuite_hooks.h>
29 bool test
__attribute__((unused
)) = true;
30 typedef std::multimap
<int, int> Mmap
;
31 typedef Mmap::value_type value_type
;
32 typedef Mmap::iterator iterator
;
36 const iterator it1
= mm1
.insert(value_type(0, 0));
37 const iterator it2
= mm1
.insert(value_type(1, 1));
38 const iterator it3
= mm1
.insert(value_type(2, 2));
40 const value_type
vt1(2, 1);
41 const iterator it4
= mm1
.insert(it1
, vt1
);
44 VERIFY( mm1
.size() == 4 );
45 VERIFY( *it4
== vt1
);
46 VERIFY( ++it5
== it3
);
47 VERIFY( --it6
== it2
);
48 VERIFY( *it5
== *it3
);
49 VERIFY( *it6
== *it2
);
51 const value_type
vt2(2, 0);
52 const iterator it7
= mm1
.insert(mm1
.begin(), vt2
);
55 VERIFY( mm1
.size() == 5 );
56 VERIFY( *it7
== vt2
);
57 VERIFY( ++it8
== it4
);
58 VERIFY( --it9
== it2
);
59 VERIFY( *it8
== *it4
);
60 VERIFY( *it9
== *it2
);
62 const value_type
vt3(2, -1);
63 const iterator it10
= mm1
.insert(it1
, vt3
);
66 VERIFY( mm1
.size() == 6 );
67 VERIFY( *it10
== vt3
);
68 VERIFY( ++it11
== it7
);
69 VERIFY( --it12
== it2
);
70 VERIFY( *it11
== *it7
);
71 VERIFY( *it12
== *it2
);
73 const value_type
vt4(0, 1);
74 const iterator it13
= mm1
.insert(it10
, vt4
);
77 VERIFY( mm1
.size() == 7 );
78 VERIFY( *it13
== vt4
);
79 VERIFY( ++it14
== it2
);
80 VERIFY( --it15
== it1
);
81 VERIFY( *it14
== *it2
);
82 VERIFY( *it15
== *it1
);
84 const value_type
vt5(1, 0);
85 const iterator it16
= mm1
.insert(it13
, vt5
);
88 VERIFY( mm1
.size() == 8 );
89 VERIFY( *it16
== vt5
);
90 VERIFY( ++it17
== it2
);
91 VERIFY( --it18
== it13
);
92 VERIFY( *it17
== *it2
);
93 VERIFY( *it18
== *it13
);
95 const value_type
vt6(0, -1);
96 const iterator it19
= mm1
.insert(it1
, vt6
);
98 VERIFY( mm1
.size() == 9 );
99 VERIFY( *it19
== vt6
);
100 VERIFY( it19
== mm1
.begin() );
101 VERIFY( ++it20
== it1
);
102 VERIFY( *it20
== *it1
);
104 const value_type
vt7(3, 3);
105 const iterator it21
= mm1
.insert(it19
, vt7
);
106 iterator it22
= it21
;
107 iterator it23
= it21
;
108 VERIFY( mm1
.size() == 10 );
109 VERIFY( *it21
== vt7
);
110 VERIFY( ++it22
== mm1
.end() );
111 VERIFY( --it23
== it3
);
112 VERIFY( *it23
== *it3
);
114 const value_type
vt8(2, 3);
115 const iterator it24
= mm1
.insert(mm1
.end(), vt8
);
116 iterator it25
= it24
;
117 iterator it26
= it24
;
118 VERIFY( mm1
.size() == 11 );
119 VERIFY( *it24
== vt8
);
120 VERIFY( ++it25
== it21
);
121 VERIFY( --it26
== it3
);
122 VERIFY( *it25
== *it21
);
123 VERIFY( *it26
== *it3
);
125 const value_type
vt9(3, 2);
126 const iterator it27
= mm1
.insert(it3
, vt9
);
127 iterator it28
= it27
;
128 iterator it29
= it27
;
129 VERIFY( mm1
.size() == 12 );
130 VERIFY( *it27
== vt9
);
131 VERIFY( ++it28
== it21
);
132 VERIFY( --it29
== it24
);
133 VERIFY( *it28
== *it21
);
134 VERIFY( *it29
== *it24
);