1 // { dg-do run { target c++11 } }
3 // Copyright (C) 2011-2019 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 #include <unordered_set>
22 #include <testsuite_hooks.h>
27 get_nb_bucket_elems(const std::unordered_multiset
<std::string
>& us
)
30 for (std::size_t b
= 0; b
!= us
.bucket_count(); ++b
)
31 nb
+= us
.bucket_size(b
);
38 typedef std::unordered_multiset
<std::string
> Mset
;
39 typedef Mset::iterator iterator
;
40 typedef Mset::const_iterator const_iterator
;
56 VERIFY( ms1
.size() == 12 );
57 VERIFY( get_nb_bucket_elems(ms1
) == ms1
.size() );
58 VERIFY( distance(ms1
.begin(), ms1
.end()) - ms1
.size() == 0 );
60 VERIFY( ms1
.erase(ms1
.begin()) != ms1
.end() );
61 VERIFY( ms1
.size() == 11 );
62 VERIFY( get_nb_bucket_elems(ms1
) == ms1
.size() );
63 VERIFY( distance(ms1
.begin(), ms1
.end()) - ms1
.size() == 0 );
65 auto it
= ms1
.begin();
67 VERIFY( ms1
.erase(ms1
.begin(), it
) != ms1
.end() );
68 VERIFY( ms1
.size() == 9 );
69 VERIFY( get_nb_bucket_elems(ms1
) == ms1
.size() );
70 VERIFY( distance(ms1
.begin(), ms1
.end()) - ms1
.size() == 0 );
72 VERIFY( ms1
.erase(*(ms1
.begin())) == 3 );
73 VERIFY( ms1
.size() == 6 );
74 VERIFY( get_nb_bucket_elems(ms1
) == ms1
.size() );
75 VERIFY( distance(ms1
.begin(), ms1
.end()) - ms1
.size() == 0 );
77 VERIFY( ms1
.erase(ms1
.begin(), ms1
.end()) == ms1
.end() );
78 VERIFY( ms1
.empty() );
79 VERIFY( get_nb_bucket_elems(ms1
) == ms1
.size() );
80 VERIFY( distance(ms1
.begin(), ms1
.end()) - ms1
.size() == 0 );