1 // 2007-02-22 Paolo Carlini <pcarlini@suse.de>
3 // Copyright (C) 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 // 6.3.4.5 Class template unordered_multiset
23 #include <tr1/unordered_set>
25 #include <testsuite_hooks.h>
27 // In the occasion of libstdc++/25896
30 bool test
__attribute__((unused
)) = true;
32 typedef std::tr1::unordered_multiset
<std::string
> Mset
;
33 typedef Mset::iterator iterator
;
34 typedef Mset::const_iterator const_iterator
;
38 ms1
.insert("because to why");
39 ms1
.insert("the stockholm syndrome");
40 ms1
.insert("a cereous night");
42 ms1
.insert("protean");
43 ms1
.insert("the way you are when");
44 ms1
.insert("tillsammans");
45 ms1
.insert("umbra/penumbra");
46 ms1
.insert("belonging (no longer mix)");
47 ms1
.insert("one line behind");
48 VERIFY( ms1
.size() == 10 );
50 VERIFY( ms1
.erase("eeilo") == 1 );
51 VERIFY( ms1
.size() == 9 );
52 iterator it1
= ms1
.find("eeilo");
53 VERIFY( it1
== ms1
.end() );
55 VERIFY( ms1
.erase("tillsammans") == 1 );
56 VERIFY( ms1
.size() == 8 );
57 iterator it2
= ms1
.find("tillsammans");
58 VERIFY( it2
== ms1
.end() );
60 // Must work (see DR 526)
61 iterator it3
= ms1
.find("belonging (no longer mix)");
62 VERIFY( it3
!= ms1
.end() );
63 VERIFY( ms1
.erase(*it3
) == 1 );
64 VERIFY( ms1
.size() == 7 );
65 it3
= ms1
.find("belonging (no longer mix)");
66 VERIFY( it3
== ms1
.end() );
68 VERIFY( !ms1
.erase("abra") );
69 VERIFY( ms1
.size() == 7 );
71 VERIFY( !ms1
.erase("eeilo") );
72 VERIFY( ms1
.size() == 7 );
74 VERIFY( ms1
.erase("because to why") == 1 );
75 VERIFY( ms1
.size() == 6 );
76 iterator it4
= ms1
.find("because to why");
77 VERIFY( it4
== ms1
.end() );
79 iterator it5
= ms1
.find("umbra/penumbra");
80 iterator it6
= ms1
.find("one line behind");
81 VERIFY( it5
!= ms1
.end() );
82 VERIFY( it6
!= ms1
.end() );
84 VERIFY( ms1
.find("the stockholm syndrome") != ms1
.end() );
85 VERIFY( ms1
.find("a cereous night") != ms1
.end() );
86 VERIFY( ms1
.find("the way you are when") != ms1
.end() );
87 VERIFY( ms1
.find("a cereous night") != ms1
.end() );
89 VERIFY( ms1
.erase(*it5
) == 1 );
90 VERIFY( ms1
.size() == 5 );
91 it5
= ms1
.find("umbra/penumbra");
92 VERIFY( it5
== ms1
.end() );
94 VERIFY( ms1
.erase(*it6
) == 1 );
95 VERIFY( ms1
.size() == 4 );
96 it6
= ms1
.find("one line behind");
97 VERIFY( it6
== ms1
.end() );
99 iterator it7
= ms1
.begin();
105 VERIFY( ms1
.erase(*it8
) == 1 );
106 VERIFY( ms1
.size() == 3 );
107 VERIFY( ++it7
== it9
);
111 iterator it11
= it10
;
113 VERIFY( ms1
.erase(*it9
) == 1 );
114 VERIFY( ms1
.size() == 2 );
115 VERIFY( ++it10
== ms1
.end() );
117 VERIFY( ms1
.erase(ms1
.begin()) != ms1
.end() );
118 VERIFY( ms1
.size() == 1 );
119 VERIFY( ms1
.begin() == it11
);
121 VERIFY( ms1
.erase(*ms1
.begin()) == 1 );
122 VERIFY( ms1
.size() == 0 );
123 VERIFY( ms1
.begin() == ms1
.end() );