1 // 2005-10-08 Paolo Carlini <pcarlini@suse.de>
3 // Copyright (C) 2005 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 // 6.3.4.6 Class template unordered_multimap
23 #include <tr1/unordered_map>
25 #include <testsuite_hooks.h>
30 bool test
__attribute__((unused
)) = true;
32 typedef std::tr1::unordered_multimap
<std::string
, int> Mmap
;
33 typedef Mmap::iterator iterator
;
34 typedef Mmap::const_iterator const_iterator
;
35 typedef Mmap::value_type value_type
;
39 mm1
.insert(value_type("all the love in the world", 1));
40 mm1
.insert(value_type("you know what you are?", 2));
41 mm1
.insert(value_type("the collector", 3));
42 mm1
.insert(value_type("the hand that feeds", 4));
43 mm1
.insert(value_type("love is not enough", 5));
44 mm1
.insert(value_type("every day is exactly the same", 6));
45 mm1
.insert(value_type("with teeth", 7));
46 mm1
.insert(value_type("only", 8));
47 mm1
.insert(value_type("getting smaller", 9));
48 mm1
.insert(value_type("sunspots", 10));
50 mm1
.insert(value_type("you know what you are?", 5));
51 mm1
.insert(value_type("the collector", 6));
52 mm1
.insert(value_type("the hand that feeds", 7));
53 VERIFY( mm1
.size() == 13 );
55 iterator it1
= mm1
.begin();
59 iterator it3
= mm1
.erase(it1
);
60 VERIFY( mm1
.size() == 12 );
62 VERIFY( *it3
== *it2
);
64 iterator it4
= mm1
.begin();
71 iterator it6
= mm1
.erase(it4
, it5
);
72 VERIFY( mm1
.size() == 10 );
74 VERIFY( *it6
== *it5
);
76 const_iterator it7
= mm1
.begin();
80 const_iterator it8
= it7
;
82 const_iterator it9
= mm1
.erase(it7
);
83 VERIFY( mm1
.size() == 9 );
85 VERIFY( *it9
== *it8
);
87 const_iterator it10
= mm1
.begin();
89 const_iterator it11
= it10
;
94 const_iterator it12
= mm1
.erase(it10
, it11
);
95 VERIFY( mm1
.size() == 5 );
96 VERIFY( it12
== it11
);
97 VERIFY( *it12
== *it11
);
99 iterator it13
= mm1
.erase(mm1
.begin(), mm1
.end());
100 VERIFY( mm1
.size() == 0 );
101 VERIFY( it13
== mm1
.end() );
102 VERIFY( it13
== mm1
.begin() );