1 // 2007-02-22 Paolo Carlini <pcarlini@suse.de>
3 // Copyright (C) 2007-2017 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 3, 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 COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
20 // 6.3.4.6 Class template unordered_multimap
22 #include <tr1/unordered_map>
24 #include <testsuite_hooks.h>
26 // In the occasion of libstdc++/25896
29 typedef std::tr1::unordered_multimap
<std::string
, int> Mmap
;
30 typedef Mmap::iterator iterator
;
31 typedef Mmap::const_iterator const_iterator
;
32 typedef Mmap::value_type value_type
;
36 mm1
.insert(value_type("because to why", 1));
37 mm1
.insert(value_type("the stockholm syndrome", 2));
38 mm1
.insert(value_type("a cereous night", 3));
39 mm1
.insert(value_type("eeilo", 4));
40 mm1
.insert(value_type("protean", 5));
41 mm1
.insert(value_type("the way you are when", 6));
42 mm1
.insert(value_type("tillsammans", 7));
43 mm1
.insert(value_type("umbra/penumbra", 8));
44 mm1
.insert(value_type("belonging (no longer mix)", 9));
45 mm1
.insert(value_type("one line behind", 10));
46 VERIFY( mm1
.size() == 10 );
48 VERIFY( mm1
.erase("eeilo") == 1 );
49 VERIFY( mm1
.size() == 9 );
50 iterator it1
= mm1
.find("eeilo");
51 VERIFY( it1
== mm1
.end() );
53 VERIFY( mm1
.erase("tillsammans") == 1 );
54 VERIFY( mm1
.size() == 8 );
55 iterator it2
= mm1
.find("tillsammans");
56 VERIFY( it2
== mm1
.end() );
58 // Must work (see DR 526)
59 iterator it3
= mm1
.find("belonging (no longer mix)");
60 VERIFY( it3
!= mm1
.end() );
61 VERIFY( mm1
.erase(it3
->first
) == 1 );
62 VERIFY( mm1
.size() == 7 );
63 it3
= mm1
.find("belonging (no longer mix)");
64 VERIFY( it3
== mm1
.end() );
66 VERIFY( !mm1
.erase("abra") );
67 VERIFY( mm1
.size() == 7 );
69 VERIFY( !mm1
.erase("eeilo") );
70 VERIFY( mm1
.size() == 7 );
72 VERIFY( mm1
.erase("because to why") == 1 );
73 VERIFY( mm1
.size() == 6 );
74 iterator it4
= mm1
.find("because to why");
75 VERIFY( it4
== mm1
.end() );
77 iterator it5
= mm1
.find("umbra/penumbra");
78 iterator it6
= mm1
.find("one line behind");
79 VERIFY( it5
!= mm1
.end() );
80 VERIFY( it6
!= mm1
.end() );
82 VERIFY( mm1
.find("the stockholm syndrome") != mm1
.end() );
83 VERIFY( mm1
.find("a cereous night") != mm1
.end() );
84 VERIFY( mm1
.find("the way you are when") != mm1
.end() );
85 VERIFY( mm1
.find("a cereous night") != mm1
.end() );
87 VERIFY( mm1
.erase(it5
->first
) == 1 );
88 VERIFY( mm1
.size() == 5 );
89 it5
= mm1
.find("umbra/penumbra");
90 VERIFY( it5
== mm1
.end() );
92 VERIFY( mm1
.erase(it6
->first
) == 1 );
93 VERIFY( mm1
.size() == 4 );
94 it6
= mm1
.find("one line behind");
95 VERIFY( it6
== mm1
.end() );
97 iterator it7
= mm1
.begin();
103 VERIFY( mm1
.erase(it8
->first
) == 1 );
104 VERIFY( mm1
.size() == 3 );
105 VERIFY( ++it7
== it9
);
109 iterator it11
= it10
;
111 VERIFY( mm1
.erase(it9
->first
) == 1 );
112 VERIFY( mm1
.size() == 2 );
113 VERIFY( ++it10
== mm1
.end() );
115 VERIFY( mm1
.erase(mm1
.begin()) != mm1
.end() );
116 VERIFY( mm1
.size() == 1 );
117 VERIFY( mm1
.begin() == it11
);
119 VERIFY( mm1
.erase(mm1
.begin()->first
) == 1 );
120 VERIFY( mm1
.size() == 0 );
121 VERIFY( mm1
.begin() == mm1
.end() );